Industry guru Dave Taylor offers tech support on technical and business topics, including iPhone, iPod, Microsoft Windows, Sony PSP, cellphones, online advertising, CSS, Web design, business, Unix, Linux, SEO, Mac OS X, and shell script programming.     


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!


More Useful Mac OS X Help Articles:
✔   Audacity can't find LAME library, I can't save Mp3?
Hey Dave. I read your article Audacity can't save mp3 audio files and am still puzzled because I downloaded the LAME Mp3 converter...
✔   How to remove Dashboard as a "space" in Mac OS X Spaces?
I'm a big fan of the Spaces utility in Mac OS X that lets me have multiple virtual screens [see Set Up Mac...
✔   Best place to buy a cheap MacBook laptop?
Hi Dave. I am looking for two gently used MacBook laptops for my teen daughters. Personal computers would greatly facilitate their studies as...
✔   File too big error copying to USB flash drive on my Mac?
I'm baffled. I have a 16GB Kingston USB flash drive that I use on my Mac system and I'm trying to copy a...
✔   Stealth image capture photo from webcam on my Mac?
Someone sneaks into my cubicle while I'm at lunch and takes candy out of my desk. Petty, but stupid too. I want to...

Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
    Enter your name: and your email addr:  









Reader Comments To Date: 107

Philip said, on October 1, 2007 7:31 PM:

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!

gerrydunlop said, on January 29, 2008 8:20 AM:

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.

Axel said, on March 7, 2008 6:13 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)

chris said, on April 3, 2008 10:24 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 :)

chris said, on April 3, 2008 11:01 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.

scott said, on June 14, 2008 3:39 PM:

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

Julie said, on October 16, 2008 1:57 PM:

Perfect! Thanks!

Lori said, on December 6, 2008 3:13 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.

Magnus Janson said, on December 18, 2008 3:00 PM:

Thanks, very big thanks

Johanna said, on December 28, 2008 12:05 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!

Alberto said, on January 26, 2009 11:48 AM:

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

Ron Barnes said, on February 19, 2009 4:42 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

Diana said, on February 20, 2009 8:50 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

ShRobbo said, on April 5, 2009 1:16 PM:

Thank you so much, this was really helpful!

Charrals said, on May 8, 2009 6:36 PM:

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

Take it easy ;)

name1 said, on May 13, 2009 10:16 AM:

thank you verymuch. this was a big help.

Diane said, on May 22, 2009 2:43 PM:

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

Mac-User said, on June 24, 2009 1:59 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!

Broker Jones said, on July 3, 2009 8:18 PM:

Lifesaver!

TexEdit was really pissing me off!!

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

Broker Jones

Melanie said, on July 14, 2009 4:52 AM:

Hi Dave,

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

Thanks Again
Melanie

Linda said, on July 22, 2009 4:27 PM:

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

Thanks

Gail Ward said, on July 23, 2009 2:41 AM:

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.

Matthew Bender said, on August 19, 2009 12:58 PM:

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

Paul Norwine said, on August 21, 2009 12:04 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

simon Phillips said, on October 2, 2009 3:31 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!!!

Rajendra Bhole said, on October 12, 2009 7:07 AM:

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.

Ann Lew said, on October 19, 2009 9:49 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?

Mimi said, on October 23, 2009 1:49 PM:

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. :)

Mark Crawford said, on October 28, 2009 4:53 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.

mario isita said, on November 4, 2009 6:36 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!

Annonymous said, on November 28, 2009 4:10 PM:

Thanks, this helped a lot!

P.S. To all of you unable to view pages you make in browsers, I suffered this problem for a while as well. I figured out that you have to do a couple things to the code itself:
1. Declare a !DOCTYPE in the first line of the code. If you don't know what that is, Google it.
2. Put this line of code in your head:
meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
And if you are using CSS:
meta http-equiv="Content-Style-Type" content="text/css"
*I removed the >s and <s because they would not be displayed. You still have to put the brackets in your actual code.

Michael Smith said, on December 19, 2009 1:48 PM:

thank you!!!!

Someone Learning Html said, on December 21, 2009 6:28 PM:

Extremely Helpful. Thank you

Quinn Deveraux said, on January 6, 2010 3:05 PM:

I'm learning to create a web page using TextEdit on a mac. Essentially I pasted:


My big ole bad page!


Hello Joe!

and saved the file as HTML. The icon it opens in a browser (firefox or safari) just fine but all I get is the sam code back:


My big ole bad page!


Hello Joe!

and not

My big ole bad page

Hello Joe!


Help? and thanks in advance.

jenny said, on January 16, 2010 8:10 PM:

Thank you!!!!!!!!

Tina said, on February 1, 2010 11:16 PM:

You are my new demigod, as I learn to work with html, editing a site on my own computer for the first time instead of on the biz' setup. Thank you for your clear explanation!

Jerry said, on February 24, 2010 12:30 PM:

Thanks Dave,

I'm just starting out and one goal is to change things in my website built by a friend a couple of years ago.

Your article really helped!

Best,
Jerry

Melissa Gonzales said, on February 24, 2010 8:12 PM:

SHOOOOT MAN.
You are awesome! :)
Life saver. I was about to quit. Buuuut. Good
I saw this. Thankyou.
This helped me, BIGTIME.
:-bd

Praveen Puri said, on March 12, 2010 9:27 AM:

Thanks Dave!

It was handy advice that worked - just when I needed it.

Praveen

Diana Kohne said, on April 14, 2010 9:48 PM:

Thanks Dave! I also just migrated from PC to Mac and use HTMl! You saved me!

steve said, on May 20, 2010 5:14 PM:

You have saved me so much time!!

vferre said, on June 15, 2010 6:29 AM:

that was perfect! tks a lot!

Zeke Zarnosky said, on June 23, 2010 11:15 AM:

Editing html in Mac OS X 10.6

While I can edit with TextEdit, I find also available is Dashcode. I like the colored/formatted etxt. Are there any pros/cons to use of Dashcode simply for editing (not making projects or widgets etc)? Thanks in advance!

Dave Taylor said, on June 24, 2010 7:54 AM:

Zeke, I don't have much experience with Dashcode, but I can't imagine why it would be a problem!

Kevin Melanson said, on June 28, 2010 9:06 AM:

Thank you for explaining this to us. It will be a great help for many years to come.

Siti said, on July 16, 2010 5:31 AM:

Wow thanks! This is so helpful. :)

Dave said, on September 5, 2010 1:06 PM:

This is such a basic thing, but it was messing me up along with all of these other folks. And driving me nuts. Now I understand that rich text must use html tags as well. I thought maybe text editor was acting like a brower! So confusing. Thanks very much for posting this!!!!

Johannes said, on September 7, 2010 12:14 PM:

WOW. Thanks.

meerkat said, on September 8, 2010 5:56 AM:

This doesn't fricking work. Mac OS is worthless for editing HTML.

SAY said, on September 22, 2010 5:43 AM:

GREAT STEPS!! Worked for me! :)

adasd said, on October 4, 2010 9:58 AM:

Thank You!!!!

Steve said, on October 8, 2010 12:48 PM:

thanks this really helped me out!

Anonymous said, on October 12, 2010 3:52 AM:

WOW!!! This article was very helpful.

It was concise, clearly laid out, and addressed every last problem that one faces with using the mac text edit application.

Thank you!

Asad said, on October 17, 2010 7:21 AM:

this is really helpful thanks a lot

Rami Tawil said, on October 19, 2010 4:48 AM:

CHAMPION!

Jonathan Rogers said, on October 22, 2010 9:52 AM:

Thanks, Dave. This is a big help.

jane said, on November 2, 2010 10:38 AM:

ORZ thanks a zillion

dhara said, on November 19, 2010 4:28 AM:

hello..
i am not able to see the desired webpage on safari on double clicking the .html file.
it shows the same coding that is there in text edit.
please help me for the same.

Chantal Ouellette said, on November 22, 2010 1:18 PM:

THANK YOU sooooo much!
I was getting desperate trying to open an html file to get a code.
You have been of great help breaking it down step by step in a very visual manner. When you're a newbie in this internet world it's surprising the small things that get in your way.
Once again, thank you!

Lidya said, on December 4, 2010 4:28 PM:

Thank you very much!
You're very helpful here... the problem made me upset, but now it's solved! Wish you good days!

aman said, on December 31, 2010 3:01 AM:

super duper tanx....solved ! im thrilled

Jayne said, on February 1, 2011 10:18 AM:

I have the same problem as the two posted questions below. I did not see an answer. Please help. I don't know why this is not working.

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.

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.

J.C said, on February 6, 2011 7:07 PM:

THANK YOU!! I never would have figured this out without tearing chunks out of my hair.

Enid Parry said, on February 8, 2011 8:59 AM:

I followed all your steps & still get the web page displaying but in TextEdit, not the code. What else can I do?

francis said, on February 16, 2011 12:40 PM:

Worked great. Danke!
However... after changing a file, I opened the site in "iWeb". I published the entire site, looked at the coding and the changes were not saved.
1) i read about having to rename the site, exit the Safari browser and iWeb to then view any new changes. I have done used this process in the past, it works great.
2) on the other hand i attempted this process after changing coding in TextEdit but was not successful.

any suggestions?

V/R

Francis

Marco said, on February 25, 2011 9:53 AM:

Hi, i wanna design my website with html codes and im using text edit, but when i open the html file with safari or firefox just displays the same as text edit file, what can i do to make the browsers open my html as a web site???

Kitty said, on March 17, 2011 11:23 AM:

I am taking an html class, where we work on pc's using notepad. However, I work on a Mac at home. If I save my files in textedit as .htm will I be able to work with them on the pc in notepad when I go back to class?

Thanks, great help here!

Taylor said, on March 18, 2011 11:49 AM:

Thank you so much!! This post was a lifesaver.

benjamin said, on March 21, 2011 2:20 PM:

Thanks so much!!
i have wanted to know how to do this for such a long time!! i use snow leopard and the option is still there. thanks again!

marie said, on April 3, 2011 7:46 PM:

Thank you so much!!!!! God bless

Louise said, on April 14, 2011 6:25 AM:

Dear Dave,
Thanks so much for this advice about text edit which is a life saver!
Like most of your viewers on this page I am new to a mac. Now that, thanks to you, I have worked out how to edit html text on textedit I am struggling to replace pictures. I select a pic in iphoto, click 'export' then 'web pg' then 'export'.. the pic appears in my web folder but not replacing the previous picture, it appears in a separate folder called 'images' and doesn't seem to relate at all to any of my original files, I can't see how to replace them. Please help!
Many thanks, Louise.

Emmanuel said, on April 15, 2011 8:25 AM:

Worked perfectly for me! thanks for the tip.

Gabor said, on May 4, 2011 1:05 PM:

Ah, that was the trick I was hoping to find. Thou art thankt.

austin said, on May 24, 2011 8:05 AM:

thanks a lot, this helped out my whole class

E.J. said, on May 27, 2011 10:13 AM:

Thanks! This enabled me to re-open my textedit html files and see my code. It was still showing as code in my browser, though, like some other still-confused people said here. I saw in TextEdit, Preferences, that under New Document, I needed to change to "plain text". That worked for new files from then on. For one I'd created already, I could now see all this rich text "html" in there that looked ok to me but it was only when I deleted all that stuff that that file opened correctly in the browser.

Richard said, on June 20, 2011 11:31 PM:

Dave, you're a legend! Your help was so clear and easy to understand. Thank you indeed sire.

Matthew Guay said, on August 15, 2011 8:05 AM:

Thanks ... you just saved my sanity.

Hadi said, on August 17, 2011 10:51 AM:

Worked for me. Great!

magz said, on August 19, 2011 10:02 PM:

u r a star! thanks for the wonderful step by step guide!

Mike Lampton said, on September 11, 2011 6:25 PM:

THANK YOU DAVE WORKS GREAT and I am personally astounded that Apple's default is to edit a html with Safari, which it cannot do!

Appreciate your work!
XXX
Mike

naveen said, on September 13, 2011 8:27 AM:

have the same prob as few others had it...when i open the html file in safari...entire code is displayed..i checked the suggested solution...declared the doc type and meta content as well in the html file code...however, it is still not opening in the web mode/formatted mode. Kindly help.

Gabo said, on September 20, 2011 7:43 PM:

I am working with TextEdit in a MacBook Pro. OS 10.6.8. I change TextEdit default setting to Plain Text. I wrote the html and save it as .html but when I opened with Firefox or any browser the page opens in the browser window showing the exact html codes that I wrote.
For instance, I wrote a simple code to be displayed on a webpage

<html>

<head>
<title> EaseFilms Productions</title>
</head>


<body>
<h1> Pre-Production Approach </h1>
<p>
This is our best asset. The way we approach the Pre-Production phase of your film
will make the different at the time of Shooting, deal with the Post-Production, and
for Distribution.
</p>
<h4> Everything is in the details </h4>
<p>
Plan everything you will need for the production is our main goal. No time wasted.
</p>

</body>

</html>

I saved it as a .html. The default browser in my computer is set to work with Firefox, so I have now a document with the Firefox icon and the name I gave it. I double click this new document and Firefox browser opens but instead of showing the page with the Title, the body, etc. It shows the page identically as I wrote it.

Do you think you could help me to solve the problem?

I will appreciate any help.

By the way, it works fine when I use a PC and write the same .html.

Hans said, on October 1, 2011 9:50 AM:

Great man ... tnx

Feidhlim Harty said, on October 5, 2011 1:10 AM:

Clear, Concise and Exactly what was needed. Thank you.

Stacey said, on October 6, 2011 1:26 AM:

Thanks so much! This was a really big help!!

Ian Robinson said, on October 20, 2011 10:27 PM:

Thanks for the help!

et said, on December 10, 2011 5:30 PM:

This was SOOOOO helpful!!!! It totally worked. :()

max1zzz said, on December 19, 2011 11:57 AM:

Thank you!
Textedit was driving me insane when trying to do simple tweaks when find tiny tiny tiny faults in my sites

(why did i never look in preferences?)

arrikitukis said, on December 26, 2011 9:01 PM:

Thanks so much!! i thought i was going crazy trying to open my html... i'm new to mac, as you see ;)

Eve said, on January 22, 2012 12:26 PM:

Thank you so much! I can stop pulling my hair out now. :)

Allie said, on January 22, 2012 1:15 PM:

Thanks this was very helpful -- just needed to click that option in the Text Edit prefs. Working just how i need it now - viewing complete HTML text without rich formatting.

sweetbali said, on February 10, 2012 3:52 AM:

thanks a lot!! very easy to follow instructions.!

Pete McPhearson said, on March 22, 2012 4:51 AM:

Cool - Just what I needed - thanks! :)

(and now.. time to hack some html!) ;)

megha said, on April 2, 2012 1:44 PM:





 Hello Malformed HTML5 World



Hello Malformed HTML5

Welcome to the future of markup! -->



writing above html statement and saving as megha.html,but will opening megha.html its showing entire coding not the actuall

can u please guide me , i m using mac os,with google chorme as default browser

megha jain

Pragati said, on May 3, 2012 1:31 PM:

This is a great tutorial. Thanks for saving my day.

Richard W Descoteaux Jr said, on May 20, 2012 3:56 AM:

Thanks for the instruction on the mac os x because i had used the windows machine i had used to did it at the college but that was in a mac room. but when you want to start editing then you should high light the index.html and then click on text edit that is about it then you are one the way to make good web page

JARADAX said, on May 22, 2012 4:50 PM:

Your solution to the editing of html files by modifying the Get Info worked fine. But now. when I WANT to execute the html I havta change it back??? Bah! Am I missing something?

Thanks ... John ... a newby!

Dave Taylor said, on May 22, 2012 6:14 PM:

John, not sure what you mean by "execute" the HTML, but the easiest way is to just drag the file icon onto a Web browser page. It'll then open up the page and interpret it as HTML, rendering it so you can see how you're doing with your development. Hope that helps!

Lesley said, on June 10, 2012 7:36 PM:

Thanks so much Dave!

Nishigandh Joshi said, on October 4, 2012 3:58 AM:

Hi,

I am working with TextEdit in a MacBook Pro. OS 10.8.2 with TextEdit 1.8 (301).

I wrote the html and save it as .html but when I opened with Safari and Chrome the page opens in the browser window showing the exact html codes that I wrote.

Can you please help me?

Thanks
Nishigandh

Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you, Dave, for all your helpful information by buying you a cup of coffee!
 1  |  2  | All 2 Pages | Next | Last »

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











I will never send you any unsolicited email. Ever.






Check This Out Too...

 
Look for Answers
Need Help? Ask Dave Taylor!


Follow Me on Pinterest

Find Me on Google+
ADT on G+
© 2002 - 2013 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. Further, 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. My lawyer says "Thanks".
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.