Since we are about to learn how to program nice pages in XHTML and CSS, let me get at something else, that has nevertheless to do with well behaving web pages: Doctype declaration
What's a DOCTYPE, and why would I need that in my page?
A doctype says in which language the page is written - is it HTML4, is it XHTML, or something else?
There are many doctypes that could be correct for (x)html pages, and there are more that do not interest
us just yet ☺. These doctypes do not only identify the page to be written in HTML or XHTML in
general, they give the version (HTML4.01, or XHTML1.1) and they can even identify specialised kinds,
like when you want to have Frames in your pages, you need Frameset
(like the following example).
This will tell the browser that the page is written in the XHTML variant v1.0, subset for framesets.
A list with valid doctypes can be found on the W3C pages.
Since our pages are going to be XHTML 1.1 the general DTD will look like this:
In fact that's exactly what this page here has as the top two lines (before the <head> section). The second line is actually not about the Doctype, that is a namespace declaration saying the page is written in XHTML (computer language wise) and in English (human language wise). If I ever get around translating some or all of my pages into german, I will have to use this:
Important: There is this misconception that one has to put for a proper XHTML page this line as the very first line:
<?xml version="1.0" encoding="Windows-1252"?>
.
This line does exist, and it is suggested to put that for XML pages (which XHTML is a part of), but it is not a must.
And you shouldn't put it, since IE6 will get lost when it comes across that line. IE6 expects the DOCTYPE declaration to be
in the first line, and if it finds something else, it switches into quirks mode!
That's all very exciting (and all very chinese), but, again, why would I care?
There are several reasons why to include the proper DTD: