TextEdit can display HTML documents as you’d see them in a browser (although images may not appear in some cases). You can also use TextEdit as an HTML editor. You can either open an existing HTML document and view and edit the code in it, or start with a new plain text file and enter your own code.
To create a file that contains HTML code:
Create a new text document, and then choose Format > Make Plain Text.
Enter the HTML code.
To save your file, choose File > Save. Enter the extension ".html" at the end of the filename.
To view and edit HTML code in an existing document:
Choose File > Open.
Select the "Ignore rich text commands" checkbox in the Open dialog.
Locate the document and then click Open.
When you save the file, it remains a ".html" file.
To always open HTML documents in code-editing mode:
Choose TextEdit > Preferences, and then click “Open and Save.”
Below “When Opening a File,” select “Ignore rich text commands in HTML files.”
To save files with graphics, plain text files, and RTF files as HTML:
To save documents that contain embedded graphics, choose File > Save As and then choose Web Archive from the File Format menu.
To save plain text and RTF files as HTML, choose File > Save As and then choose “Web Page (.html)” from the File Format pop-up menu.
You can view HTML files in a web browser, such as Safari.