The solution provided by Xiaoou Wang works.
Explanation
I would like to extend this answer and provide below a different solution, which was not given yet.
Chrome [Mac] indeed does not open .html
files that have the extended attribute com.apple.quarantine
. This attribute is automatically applied on files
that are downloaded from the web and are not Apple-authorized applications.
From the terminal, by typing
xattr 'your .html file name'
you can verify whether your .html
file has the quarantine attribute set.
With xattr -c
command you will remove all attributes, in case there are others set. If you want to only remove the quarantine attribute, type instead
xattr -d com.apple.quarantine 'your .html file name'
Alternative solution
This alternative solution might be even simpler for some people. With my Chrome [mac] I can open
.html
files by simply dragging the file from finder onto an already opened Chrome window, in spite of their com.apple.quarantine
attribute. Important: It does not work if you drag the file onto Chrome's icon in the dock.
- Global Nav Open MenuGlobal Nav Close Menu
- Apple
- Apple
- Store
- Mac
- iPad
- iPhone
- Watch
- AirPods
- TV & Home
- Only on Apple
- Accessories
- Support
Modifying this control will update this page automatically
TextEdit User Guide
- Welcome
- Start new documents
- Open documents
- Save documents
- Work with HTML documents
- Hear documents read aloud
- Format with fonts and styles
- Adjust paragraphs
- Insert line, paragraph, and page breaks
- Change how text wraps
- Print headers and footers
- Set character and line spacing
- Set default font
- Use superscript or subscript
- Add tables and lists
- Insert special characters
- Add photos, movies, and files
- Annotate images
- Check spelling and grammar
- Find and replace text
- See word completions
- Change TextEdit preferences
- Copyright
You can use TextEdit to edit or display HTML documents as you’d see them in a browser [images may not appear], or in code-editing mode.
Note: By default, curly quotes and em dashes are substituted for straight quotes and hyphens when editing HTML as formatted text. [Code-editing mode uses straight quotes and hyphens.] To learn how to change this preference, see New Document options.
Open TextEdit for me
Create an HTML file
In the TextEdit app
on your Mac, choose File > New, then choose Format > Make Plain Text.Enter the HTML code.
Choose File > Save, type a name followed by the extension .html [for example, enter index.html], then click Save.
When prompted about the extension to use, click “Use .html.”
View an HTML document
In the TextEdit app
on your Mac, choose File > Open, then select the document.Click Options at the bottom of the TextEdit dialog, then select “Ignore rich text commands.”
Click Open.
Always open HTML files in code-editing mode
In the TextEdit app
on your Mac, choose TextEdit > Preferences, then click Open and Save.Select “Display HTML files as HTML code instead of formatted text.”
Change how HTML files are saved
Set preferences that affect how HTML files are saved in TextEdit.
In the TextEdit app
on your Mac, choose TextEdit > Preferences, then click Open and Save.Below HTML Saving Options, choose a document type, a style setting for CSS, and an encoding.
Select “Preserve white space” to include code that preserves blank areas in documents.
If you open an HTML file and don’t see the code, TextEdit is displaying the file the same way a browser would [as formatted text].
Please don’t include any personal information in your comment.
Maximum character limit is 250.
Thanks for your feedback.