TextEdit Icon

I can't view the code in an HTML file

If you drag a file to TextEdit to open it and you don't see the HTML code, TextEdit is reading the formatting as though it were a browser. If you attempt to convert the file to plain text, you'll notice that the content seems to disappear.

To view the code in an HTML file, choose File > Open and select "Ignore rich text commands." Then locate the file and click Open.

You can set up TextEdit so that it always opens HTML files as plain text and reveals the code. To do this, choose TextEdit > Preferences and click "Open and Save." Under "When opening a file," select "Ignore rich text commands in HTML files."

See also

HTML