Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

medasmx

macrumors member
Original poster
Nov 9, 2008
89
0
I have written the following on textEdit --
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http:://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>my awesome page</title>
	</head>
	<body>
		<h1>hi there</h1>
		<p>thanks for looking</p>
	</body>
</html>

It is saved under html extension. Then when I open it using safari, it just shows the same textEdit document, without any html formatting. I don't exactly know which doctype to use.

Got a book by Jonathan Stark, which is where I got this from. Any ideas?

Adam
 
Are you sure you saved it as .html? TextEdit has a nasty habit of adding .txt in addition to your .html. If you have file extensions turned off then you don't see the .txt but do see the .html.

Also: did you make it a plain text document?
 
Do a "get info" on the file and check the extension
It is possible it is saved with both html and txt as the final extension

Woof, Woof - Dawg
pawprint.gif
 
I checked and it is in html extension. The file opens up. It's just that instead of printing...

my awsome page
hi there
thanks for looking

It just prints out the original document, made in textEdit, including the <head></head>, etc.

They way I opened it in safari is by starting safari and then using "open file". The other way described is to drag the html file on top of the safari icon. This does the same thing.

Adam
 
What you're describing is often what happens when TextEdit is in rich text mode. What I suggest doing is use a developers editor rather than TextEdit, which is not meant for coding. Try out TextWrangler, which is free and will always save as plain text.
 
I saw another post that said to save it as .rtf and then switch it later to .html. I tried that and it more or less worked. I wound up with some extra stuff, however, listed below.

Code:
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf250 {\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;\red234\green234\blue234;} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \deftab720 \pard\pardeftab720\ql\qnatural \f0\fs26 \cf0 \cb2 \ \ \ \ \ \

hi there

\
thanks for looking

\ \ }

Anyway, may try that textwrangler, suggested by earlier response (angelwatt). Thanks.

Adam
 
I saw another post that said to save it as .rtf and then switch it later to .html. I tried that and it more or less worked. I wound up with some extra stuff, however, listed below.

Do not save as rtf. That will never work. Save as plain text. You need to change the document in TextEdit. If you can see the ruler/formatting toolbar you are in the wrong mode and it'll never work. You must use the Format->Make Plain Text Command. If the command under Format reads "Make Rich Text" you are already in the correct mode.
 
thanks--got it working

Got it to work, based on suggestions. What worked was saving as a .txt file, then using "get info" to convert to .html.

Thanks again.

Adam
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.