You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How do I write HTML code in Text Edit

This is really annoying or maybe I am doing something wrong. I am new to Mac and I am trying to write html code in TextEdit application. But when I write my code and save teh file as main.html, and I try opening it from safari, it opens the html code and not the html render. Am I doing something wrong? If a text file is named soemthing.html, shouldn't safari treat it as a webpage and open the page instead of showing me the code?

Any help is appreciated.

Mac OS X (10.4.6), Macbook 1.83 Ghz, iPod G5

Posted on Jun 26, 2006 6:49 PM

Reply
6 replies

Jun 26, 2006 7:08 PM in response to Huckster

The default type of document that TextEdit creates is a RichText format (.rtf) document. I think what's happening is that you're actually creating a RichText format document of HTML code.

What you'll probably want to do is to open the existing file in TextEdit and press Command-Shift-T to change from Rich Text to Plain text. Then save a copy of the file with an .html filename extension. Then open that saved copy in Safari and it should most likely work as you intended.

Now, by default, when you open the file back up in TextEdit, it will show the page to you as it would appear in a browser, rather than showing you the raw HTML code. To see the raw HTML code for a particular file, use the Open panel to open the file and click the checkbox to "Ignore rich text commands". If you would like TextEdit to always show you the raw HTML code (for example, you double-click on the HTML file in the Finder) rather than rendered HTML, open TextEdit preferences and click the checkbox for "Ignore rich text commands in HTML files" in the Open and Save tab.

Hope this helps....

P.S. Easiest way to quickly preview in Safari what you've just written in TextEdit is to drag the small "proxy" icon in the window titlebar onto an existing Safari window in the background. (The "proxy" icon is meant to represent the file as it is on disk; you'll note that it's dimmed when there are unsaved changes).


Dual 2.7GHz PowerPC G5 w/ 2.5 GB RAM; 17" MacBook Pro w/ 2 GB RAM - Mac OS X (10.4.6)

Jul 5, 2006 3:40 AM in response to MarkDouma®

Forgive the intrusion, can't find a better place for this query but...
When I choose Save As for my txt files I see no option to save as Word Format, as described in TextEdit's Help. I just want to save simple text in a format that a PC can read using Note Pad! the option onlys appears when I use Rich Text format. Please help!
Tom

Jul 5, 2006 3:58 AM in response to tomb

When I choose Save As for my txt files I see no
option to save as Word Format, as described in
TextEdit's Help. I just want to save simple text in a
format that a PC can read using Note Pad! the option
onlys appears when I use Rich Text format. Please
help!


Plain text can be read by all word processors -- there is no special format for Word. Word format (.doc) is by definition Rich Text.

Jul 5, 2006 5:18 AM in response to Tom Gewecke

Plain text can be read by all word processors


If is just plain enough. As soon as you enter things like an "ö" or "é" there may be differences between different platforms. Likewise paragraph breaks don't work the same on PCs and Macs.

The safest and easiest way to transfer text between a Mac and a PC is usually to use rich text of some kind like rtf, doc or even html, isn't it?

How do I write HTML code in Text Edit

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.