How to Edit HTML With TextEdit

A simple preference change is all you need to edit HTML in TextEdit

Screenshot of the TextEdit preferences on a Mac

Jennifer Kyrnin

TextEdit is a text editor program that ships with all Mac computers. You can use it to write and edit HTML, but only if you know a few tricks to get it to work.

When you use TextEdit to save an HTML document with the .html file extension, you'll find that when you open that file in a web browser, you can see all the HTML code, which isn't want you want.

To change how the HTML file displays in the browser, you have to change how TextEdit saves the document. You can do this with a simple change in the settings, or you can permanently alter the preferences if you plan to use TextEdit as your full-time HTML editor.

How to Save to HTML With TextEdit

Write the HTML document normally in TextEdit, but before you save to an HTML file, follow these steps to make sure that when you open the document later, the page renders properly and doesn't show all the behind-the-scenes HTML code.

  1. Go to Format > Make Plain Text.

    Another way to do this is with the Shift+Cmd+T shortcut.

  2. Go to File > Save.

  3. Change the file extension after the file name to be .html instead of .txt.

  4. Click Save.

  5. Click Use .html.

If you plan to edit lots of HTML files with TextEdit, you might prefer to make the plain text format the default option. To do that, go to TextEdit > Preferences and open the New Document tab. Change the format to Plain text.

Now, you can edit the file as HTML in any other text editor. However, if you want to edit it in TextEdit again later, you need to change some preferences.

If you don't change the TextEdit preferences, TextEdit will open your HTML file as an RTF file, and you'll lose access to all the HTML code. What this means is that you won't be able to change the <html>, <body>, <p>, and other tags; you'll see just regular text without any code.

  1. Go to TextEdit > Preferences.

  2. Click the Open and Save tab.

  3. Put a check in the box next to Display HTML files as HTML code instead of formatted text. If you're using a version of macOS older than 10.7, this option is called Ignore rich text commands in HTML pages.