The SitePoint book implies that because it is getting you used to well-formed markup within HTML 4.01 STRICT you could have this:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>title</title>
</head>
<body><p>Lorem Ipsum
Which as you can see is a good example of a VALID HTML 4.01 Strict document!
But if you are a beginner it might be confusing as to why I was allowed to omit certain tags, which is what Stephen said. Basically it is teaching the basic grammar but not the actual application of x(ht)ml or the consequences.
So what do I have to change - unlearn - in my current document?
(Sorry, but I’m really upset I just spent $40 and spent allweekend reading this Head First book and now you guys are telling me it is all wrong?!) :bawling:
Can you please help me figure out what I have to learn and unlearn.
That’s actually an excellent book for learning HTML. The (X)HTML it teaches differs in only two ways from HTML:
the doctype
The /> at the end of some tags that is just > in HTML.
The book basically covers XHTML served as HTML and not as real XHTML and so apart from the doctype it uses and a few extra / it is actually teaching easy to maintain HTML (since there are lots of things that you can leave out in HTML that are required in XHTML and which the book teaches you to include which when left out make the code harder to maintain).
By learning the XHTML syntax for web pages served as HTML first you end up with better HTML than you would if you were to learn HTML along with all the shortcuts it allows (such as leaving out <head>, <body>, </p> etc tags and letting the browser figure out where those tags should be inserted).
So basically once you have finished writing your page using the XHTML taught in that book simply replace all /> with > and change the doctype at the top to the HTML 4.01 strict version and your page will be using well written HTML 4.01 strict.
There are lots more differences than that but most of the differences can’t be used if you want Internet Explorer 8 and earlier to be able to display the web page.
even if you are using XHTML in order for Internet Explorer 8 to be able to process it at all. This is just one example of where the HTML is also valid as XHTML but where an XHTML version exists that is not valid as HTML.
Only by following the rules in Appendix C can XHTML be treated as if it were HTML and that basically reduces you to using the subset of XHTML that is effectively HTML with a few extra / and you can’t actually take any advantage of the benefits of XHTML. The only benefit that you would get is that the XHTML validator is stricter than the HTML one and so will tell you if you leave out tags that browsers have to allow for being missing in HTML but which make your page harder to maintain and once IE8 and earlier die out you will have a slightly easier time converting the page to work as real XHTML.
It’s not about newness. It’s about appropriateness. I am using it inappropriately because of long habit, and because I modified my development tools to that syntax back when I was using it correctly. The two are different, just as a newer hammer is the wrong tool if you need a screwdriver. But, a hammer will drive a screw, and xhtml may be served as html; that doesn’t mean it’s a good idea.
Why start a new thing using less than best practice?