I just started reading the book "creating a web site". It seems very promising so far, and perfect for a newbie like myself. I just finished chapter 2 and am in the process of creating my first page, which I find really exciting.
Im using TextEdit on my Mac to write the XHTML document. However, when I try to open the .html document on my Safari browser, it seems to display the exact same text as displayed on TextEdit. As above mentioned, I ́m a newbie at this, and I ́m guessing this has an obvious explanation, but I can ́t seem to get it. Any good advice?
That's because XHTML is XML and many browsers will not correctly display XHTML unless the Web server is configured to serve XHTML and the browser understands XHTML.
I recommend that instead of using XHTML you use HTML. HTML5 is the newest version of HTML and XHTML is pretty much dead at this point.
To do this, you mostly need to focus on changing the doctype. For HTML5, the doctype is simply <!doctype html>.
If you need more help, let me know. My book Head First HTML with CSS & XHTML is mostly about HTML (with one chapter about XHTML) and I'll be updating it later this year to remove the XHTML and change to HTML5. I'll also be publishing a new book on HTML5, Head First HTML5.
I hope this helps.
Thanks for the swift reply and useful information on changing the doctype. However, it didn ́t solve my problem. I have been searching for answers online, and after a while I found that a lot of people have had the same problem with opening html files in Safari after editing them in TextEdit.
I want to post the solution here for others who might have the same problem, as I spent quite a few hours to finally get the answer. Its actually a two part problem:
1: In order to display the .html document made in TextEdit as formatted text in Safari, and NOT just the html code, you have to save the document as html. However, this doesn ́t always do the trick. In my case, I had to manually write the ending .html after I save, as the document seems to be saved as .txt whatever i choose.
I finally thought I had the answer, but the problem now was that I couldn ́t open my html coding in TextEdit. It displayed only the formatted text, NOT the actual html code. So my problem now seemed to be reversed.
2: You need to change the settings in "preferences" on TextEdit.
Check out the page "Ask Dave Taylor" and youll fin a stepwise walkthrough on how to do it. Its in the "Open and Save" part of the 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
I hope this can be helpful to other beginners as myself.