I had the same problem and found this resource to help me:
- Create your HTML document by writing the HTML codes in TextEdit. But when you try to save do not choose Web Page in the file formats drop-down. If you choose this, all of your HTML codes will appear on the page.
- Go to the Format menu and choose “Make Plain Text.”
- Save the file with a .html extension. Then you can edit the file in any other text editor as plain HTML.
But if you need to edit it in TextEdit later, you need to change TextEdit preferences. If you don't change the TextEdit preferences, it will open your HTML file as an RTF file, and you will lose all your HTML codes. To change the preferences
- open TextEdit and choose “Preferences” from the TextEdit menu.
- Switch to the “Open and Save” tab.
- Make sure the checkbox is checked in front of “Display HTML files as HTML code instead of formatted text.”
- It also helps to have TextEdit default to text files (instead of Rich Text) if you use it to edit HTML a lot. To do this, switch back to the “New Document” tab and change the Format to “plain text.”