Mac Users: Beware TextEdit “File Save…” issue

OK, it’s official. We’ve gotten email from several Mac-users about our instructions on editing HTML files to report that when they open those files inside a Web browser, they see markup instead of a bona fide Web page. Apparently, this is a default behavior of TextEdit in MacOS, which sees the HTML markup in the file and invokes a built-in software tool called the Cocoa HTML Writer. If you view source on such files in your Web browser, in fact, you’ll see a preamble at the head of every such file that looks exactly like this:

<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
   <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
   <meta http-equiv=”Content-Style-Type” content=”text/css”>
   <title></title>
   <meta name=”Generator” content=”Cocoa HTML Writer”>
   <meta name=”CocoaVersion” content=”1038.35″>
   <style type=”text/css”>
       p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
       p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
    </style>
</head>

If you want to change the behavior of TextEdit, which will otherwise keep you from creating plain text HTML files of your very own, you must jump through a few hoops. That’s because TextEdit wants to save your file in RTF (Rich Text Format) by default, and re-interpret all of your HTML markup as display characters that use character entities (like &gt; instead of >, and &lt; instead of <, and so forth). Of course that makes it impossible to save and view your HTML in a Web browser, which sort of defeats the whole point.

To fix this problem, you have two options: first, you can jump through the hoops necessary to tell TextEdit how to save your file the way you want it, or you can switch from TextEdit to some other MacOS text or HTML editing tool instead. I will address each of those options in sections that follow, albeit very briefly. Interested readers of this book who are also MacOS users are invited to share their feedback and recommendations here (My first home computer was a Fat Mac 512K but I quit buying Macs in 1994 for budgetary reasons; however, my fearless co-author and bon vivant Jeff Noble remains a Mac-head himself, so maybe he’ll post a comment or an additional section to this blog, too).

Option 1: Fix TextEdit

The high-level view of this approach requires you to change the file format from Rich Text Format (RTF) to Plain Text (Format –> Make Plain Text), and then to use the Save As… dialog (File –> Save As…) to tell the editor to save the file with a “.html” file extension. The editor, annoyingly enough, will make you confirm this instruction, but once you surmount that final hurdle, you can use TextEdit on this file forever afterward without repeating this maneuver. You must, however, do this for each and every new HTML file you want to create using TextEdit (and to be fair, NotePad on Windows puts you through a similar routine for files as well, so it’s not just a crazy Mac thing; it’s apparently a crazy default built-in text editor thing that is OS independent).

That’s why I recommend you at least investigate Option 2 that follows, and why I use HTML-Kit on my Windows PCs when I start getting more serious about building an HTML page for which I don’t want to trot out Adobe DreamWeaver. To see an illustrated, step-by-step set of instructions on how to make TextEdit do all the things I’ve just described, check out the page entitled “How do I save HTML files from TextEdit?” at AskDaveTaylor.com (“Vielen Dank und besten Glückwünschen!” to German resident and reader Tanya Desia for finding and pointing this little gem out to me, to help us document and solve this problem).

Option 2: Get Another Tool…

There are two ways to go here.

  1. You can look for a text editor for MacOS that’s a little less tenacious in insisting on saving files in formats it thinks are good for you, but which don’t work terrribly well for saving HTML markup files. Under this heading, you’ll want to consult this article entitled “10 Most Popular Free Mac OS Text Editors for Web Developers and Programmers.”
  2. You can look for an HTML editor for MacOS that knows more about what you’re doing, but that may be irritating for newbies because it may assault you with other kinds of default behaviors that want to control your markup activity (sorry, all software has its little foibles…). To get started hunting this kind of stuff down, you’ll want to comb this listing at TheFreeCountry.com entitled “Free HTML Editors/Free Web Editors” and look for MacOS-friendly entries.

[Note: TheFreeCountry.com page is the best resource I can find after a cursory Web search for Mac-specific HTML and Web editors; if some of you Mac-heads know of a better place to start down this road, add a comment to this blog, and I’ll update same if I like what you’re recommending. TIA.]

One thought on “Mac Users: Beware TextEdit “File Save…” issue

Leave a Reply

Your email address will not be published. Required fields are marked *