simple html for safari

Discussion in 'Web Design and Development' started by medasmx, Feb 14, 2010.

  1. medasmx macrumors member

    Joined:
    Nov 9, 2008
    #1
    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
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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?
     
  3. MacDawg macrumors P6

    MacDawg

    Joined:
    Mar 20, 2004
    Location:
    "Between the Hedges"
    #3
    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 [​IMG]
     
  4. snickelfritz macrumors 65816

    snickelfritz

    Joined:
    Oct 24, 2003
    Location:
    Tucson AZ
    #4
    I copied and pasted your code into a plaintext document in TextEdit.
    Saved it as hello.html.
    Works fine in Safari.
     
  5. medasmx thread starter macrumors member

    Joined:
    Nov 9, 2008
    #5
    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
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Zip the file and upload it as an attachment...
     
  7. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #7
    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.
     
  8. medasmx thread starter macrumors member

    Joined:
    Nov 9, 2008
    #8
    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
     
  9. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #9
    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.
     
  10. Darth.Titan macrumors 68030

    Darth.Titan

    Joined:
    Oct 31, 2007
    Location:
    Austin, TX
    #10
    +1 on making sure to go to Format->Make Plain Text.

    Save yourself some confusion and get a plain text editor like TextWrangler. It's free and will make your life easier.
     
  11. medasmx thread starter macrumors member

    Joined:
    Nov 9, 2008
    #11
    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
     

Share This Page