Industry guru Dave Taylor offers free tech support on a wide variety of technical and business topics, including HTML, Apple iPhone, online advertising, Cascading Style Sheets, Web design, management, Unix, Linux, search engine optimization, online dating, Mac OS X, shell script programming and Microsoft Windows.

How do I use TextEdit with HTML files on Mac OS X?

I wrote all of my web site's code using SimpleText in MacOS 9. Recently I made the step up to OS X and I've transferred all of my data from my old G-4 to the new system. When I open the html pages in TextEdit on OS X I am unable to go in and edit the code. Instead I get a screen that reads the the html and presents a page like one would see on the web. Is it possible to edit the html that was written in SimpleText and still keep it as a text file?


Dave's Answer:

There are a couple of ways you can address this problem. First off, in Mac OS X, files with ".html" filename suffixes are automatically associated with Safari, the Web browser, so if you double click on them, you don't get to an editor at all.

To open a file in your editor, Control-Click on the file's icon. You'll see:

Mac OS X Open With... menu

You can see here that, oddly enough, I have three different versions of TextEdit on my own computer running Mac OS X Tiger 10.4.2. Weird!

Anyway, that's the general technique you can use to open any file in Mac OS X with any of the set of applications that are known to handle that particular file type.

To permanently change all ".html" files to open with TextEdit, instead of choosing "Open With..." you should choose "Get Info..." which reveals the following:

Mac OS X Get Info window

Notice the "Open with" area in the Get Info window. As you can see, the default is to open this file -- and all files with this matching filename extension -- with Safari. You can change that by selecting another application from the pop-up menu, then clicking Change All....

Now, on to the specifics of your question. You ask why it is when you open up an HTML file that TextEdit shows you the formatted text rather than the actual HTML source. Great question!

Here's what I see when I open a simple HTML file:

TextEdit showing formatted HTML rather than source

Not good. To fix this we're going to have to change the Preferences, then quit and re-open the file. Fortunately, we'll only have to do this once on your Mac. Go to TextEdit --> Preferences... and choose "Open and Save". You'll see:

TextEdit Preferences

The key is the first option under "When opening a file": you want to check Ignore rich text commands in HTML files. Check that option, then quit TextEdit.

Now, open up the HTML file again, and here's what you'll see:

TextEdit showing HTML source

Much, much better.

It turns out you can also do this by manually selecting File --> Open..., choosing the file, and also selecting the option in the Open dialog window of "Ignore rich text commands", but since i'm always double-clicking on files or otherwise launching TextEdit, it's a much easier solution to simply fix the preferences and never worry about it again.

Kind of a pain, but that's your solution path. Good luck with your editing!



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon    

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments

Dear Dave, i use a mac OSX(10.3) to do my site. Recently, i thought of purchasing a CGI script for my site but i have no idea, can a CGI script work with mac? I'm not a techie so need your help. Thanks mate!

Posted by: Philip at October 1, 2007 7:31 PM

Dave, you're a sanity-saver. I was going spare trying to write website stuff on my newly acquired Mac. It's so much easier on Windows. Will buy you a chai soon (promise), when I've recovered from Mac-trauma.

Posted by: gerrydunlop at January 29, 2008 8:20 AM

This is weird indeed. When I open an HTML file, TextEdit looses a couple of my CSS styles. So I decided to untick the box and to display all the HTML code.
The thing is that when you untick this box, you cannot save the html file as webarchive any longer. Annoying...
(trying to make a signature for Mail)

Posted by: Axel at March 7, 2008 6:13 AM

I don't know why this did not work for me, I tried everything with no success.
I have OS X 10.4.11. When I try to open the ".html" file with TextEdit 1.4, I get a blank white screen....very frustrating.
Then I remember that you can double click to open the ".html" file which opens your default browser, (I was using Safari) click View > View Source and then you can see the "html" text... hope this helps :)

Posted by: chris at April 3, 2008 10:24 AM

IT Works!!!!

NEXT STEP ... copy the ".html" text and paste into new TextEdit file and save over your old file in the same location!
I found out that I could only edit the ".html" text in a new TextEdit file.

Posted by: chris at April 3, 2008 11:01 AM

Thanks for the help. That solved my problem immediately. Why does Apple not make this the default ?

Posted by: scott at June 14, 2008 3:39 PM

Perfect! Thanks!

Posted by: Julie at October 16, 2008 1:57 PM

Thank you! This has been a bigger and bigger thorn in my side as my family has slowly migrated more and more of our pcs to macs. I can work from home again!

I agree with a previous commenter, why isn't plain text the default? If we want to see what it looks like in HTML, we can open a browser.

Posted by: Lori at December 6, 2008 3:13 PM

Thanks, very big thanks

Posted by: Magnus Janson at December 18, 2008 3:00 PM

YAY! I was getting very frustrated with this problem, and your page was the first thing to come up in Google. It WORKED, and I am thrilled. THANK YOU!

Posted by: Johanna at December 28, 2008 12:05 PM

Thank you very much..saved my day..!!

Posted by: Alberto at January 26, 2009 11:48 AM

Dave,

I accidentally trashed a memory stick containing vital data and text. The stick was written with SimpleText on Mac OS 9.2.2 I was unable to find any software to recover the files on 9.2.2 but I have recovered them with DataRescue on Mac OS 10.4.11 They only open with TextEdit as in the following examples

Posted by: Ron Barnes at February 19, 2009 4:42 AM

This tip is a sanity saver! I'm used to using Notepad and was about to give up on TextEdit. I have one more problem when using TE for HTML. No images show up, even thought my path and spelling of the file name is correct. Neither a page background image or an inline image will show. Any ideas?

Thanks

Posted by: Diana at February 20, 2009 8:50 AM

Thank you so much, this was really helpful!

Posted by: ShRobbo at April 5, 2009 1:16 PM

Thank you very much man. I was getting annoyed with the silly default interpretation of HTML files by TextEdit.

Take it easy ;)

Posted by: Charrals at May 8, 2009 6:36 PM

thank you verymuch. this was a big help.

Posted by: name1 at May 13, 2009 10:16 AM

I'm just learning how to use a mac and this was SOOO helpful! THANK YOU!

Posted by: Diane at May 22, 2009 2:43 PM

This really helped. My Dad is making small html documents for us, when he couldn't edit them again after closing them, he got upset. This explained everything!

Posted by: Mac-User at June 24, 2009 1:59 PM

Lifesaver!

TexEdit was really pissing me off!!

I googled, I found this, and the problem was fixed!

Broker Jones

Posted by: Broker Jones at July 3, 2009 8:18 PM

Hi Dave,

Thanks for that info I was having a real lot of trouble, you have saved my day! Yeah.

Thanks Again
Melanie

Posted by: Melanie at July 14, 2009 4:52 AM

It is so great to have people like you out there that will help beginners like us. You saved the day!!

Thanks

Posted by: Linda at July 22, 2009 4:27 PM

I am writing an HTML document in text edit on my macbook pro and when I open up with my browser firefox (or safari) it is just displayed as the text not interpreted HTML
All the tags are still showing.

Posted by: Gail Ward at July 23, 2009 2:41 AM

Wow, thanks! This was so frustrating
Now I don't have to consider turning on my PC *shudder*

Posted by: Matthew Bender at August 19, 2009 12:58 PM

Dave - thanks for your step-by-step. I was getting increasingly frustrated and couldn't find what I was looking for until I came across your site. Thanks for making it easy :)

Paul

Posted by: Paul Norwine at August 21, 2009 12:04 PM

Hi,
I am trying to edit the html for my website to add keywords, title etc and don't know how to do it!
I have iweb 09 version 3....

Please help as I don't want to go back to my pc to do it!!!

Posted by: simon Phillips at October 2, 2009 3:31 PM

How i executing and running the PHP code in the mac o.s. Also i can't enable to execute the HTML code from above procedure. After that i used the the HTML file openwith in the Firefox browser then it worked.

Posted by: Rajendra Bhole at October 12, 2009 7:07 AM

I have the opposite problem. It only shows the HTML and not the formatted text when I open a new browser. I have checked and unchecked the Ignore rich text commands in HTML to see if there would be any difference. No change. Suggestions?

Posted by: Ann Lew at October 19, 2009 9:49 AM

THANK YOU
I resorted to using my husband's clunky IBM from 2000 to update my site, wish I'd discovered this about a year ago. :)

Posted by: Mimi at October 23, 2009 1:49 PM

Help I have a similar but slightly different problem to what you describe above. When I click on a simple html file on my desktop, it opens in Safari, which is what I want it to do, but displays like a textedit file, showing the htiml code instead of displaying as a regular we page.

Posted by: Mark Crawford at October 28, 2009 4:53 PM

thank you A LOT!!! i was getting mad!!! very clear and simple explanation! now after this thanking i go to read ALL your posts!

Posted by: mario isita at November 4, 2009 6:36 PM

I have a lot to say, but ...
Starbucks coffee cup I have a lot to say, and questions of my own for that matter, but most of all I'd like to say thank you for all your efforts on this Web site by buying you a chai!

I do have a comment, now that you mention it!











Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









snow leopard pre order advert amazon

Follow me on Twitter @DaveTaylor

Search
Find just the answers you seek from among our 2300+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Book Links
© 2002 - 2009 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.