Discuss: Fix Your Site With the Right DOCTYPE!
by Jeffrey Zeldman
- Editorial Comments
12 DOCTYPEs for browsers
“So someone clear up what the browser is actually doing when it wants a doctype. Is it actually going out to the URI […]? or, is the browser just matching the doctype it sees on the top of your html document to a list of known doctypes […]”
Pretty unlikely that a browser actually cares whether the URI is valid or not, let alone what’s inside it.
“What if, like Netscape did with I believe the RSS doctype, they just decide to move, and tweak it.”
That’s why they won’t move it ;-)
posted at 01:32 am on April 12, 2002 by Kevin W
13 DOCTYPE on two lines?
Is there a reason why everyone puts the DOCTYPE declaration on two lines (the URI on the second)? Or is it just because it’s supposed to be easier to read?
posted at 01:39 am on April 12, 2002 by Kevin W
14 RE: XML; RE: DOCTYPE on two lines?
>> IE6 triggers quirks mode if there is an XML declaration present.
> You’ve got to be kidding me. Is this seriously the case?
Unfortunately, it is. I’ve confirmed it on my own. The only way to trigger “standards” mode in IE6 is to forego the use of the XML declaration.
> Doesn’t the standard REQUIRE the XML declaration at the top, above the DOCTYPE tag?
If you use both an XML declaration and a DOCTYPE, the XML declaration must be on the first line, followed by the DOCTYPE on the second line. But as riffola said, you can lose the XML declaration if you specify the document encoding type in a <meta> element. This may not be ideal, but it’s a valid workaround. Our salvation is that Microsoft will have released a new browser version by the time the next version of XML is released and we’re forced to use an XML declaration to comply.
> Is there a reason why everyone puts the DOCTYPE declaration on two lines (the URI on the second)? Or is it just because it’s supposed to be easier to read?
It’s easier to read. Like most anything in XML, the amount of white-space between different parts of an element (element names, attributes, etc.) is irrelevant so long as there is any amount. You can have a dozen spaces, five tabs, and 16 line breaks between each element part and the parser won’t care.
posted at 02:34 am on April 12, 2002 by Greg H.
15 RE: What Greg H. Said
Thanks much for the clarity Greg. I’ve been searching for the answer to the xml-declaration-IE-quirks-mode bug for some time, and had no idea that it could be so obvious a solution.
Good article as well: concise, and informative.
posted at 03:17 am on April 12, 2002 by komlenic
16 DOCTYPE obfuscation
> sort of odd that HTML 4.01 would have a doctype, since aren’t doctypes one of those XML things? :)
Nope…they’re one of those SGML things. Even HTML 3.2 has a DOCTYPE.
Another thing that’s been bugging me:
BBEdit likes to use DOCTYPES like this (for XHTML 1.0 Transitional, for example):
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd”>
which, if you bother to go to the URL specified, contains a proper XHTML DTD (the same one, I’m fairly certain, as if you go to the URL specified in the article). This URL causes browsers to enter standards mode (good), and is valid according to the W3C (X)HTML validator (also good). However, when one attempts to run a page with this DOCTYPE through the W3C’s CSS validator, it chokes, proclaiming it an invalid DOCTYPE (which it clearly is not).
Annoying.
posted at 03:35 am on April 12, 2002 by Wevah
17 more resources
HTML4.01/3.2/2.0 DOCTYPES:
http://www.htmlhelp.com/tools/validator/doctype.html
Some VERY useful info on DOCTYPES and browser behaviour:
http://www.allmyfaqs.com/faq.pl?DOCTYPE
posted at 04:09 am on April 12, 2002 by Kris
18 Language
There´s one thing I don´t understand about this one:
<html >
Does the lang=“en” elements refer to the language used in the document? Do I have to write lang=“fr” if there´s french text on the page?
posted at 04:43 am on April 12, 2002 by Didier
20 re: Language
Yes, lang=“en” says that the document is in English. If you have some inline French you can stick it in <span lang=“fr”>le blah</span>.
posted at 05:20 am on April 12, 2002 by Jackie McGhee
Discussion Closed
New comments are not being accepted, but you are welcome to explore what people said before we closed the door.
Got something to say?
Discuss this article. We reserve the right to delete flames, trolls, and wood nymphs.
Create a new account or sign in below if you’d like to leave a comment.
Subscribe to this article's comments: RSS (what’s this?)






11 In the nick-of-time...
Nice article, I already knew where the DOCTYPEs were located in the site. But, it’s true; it’s a virtual Indiana Jones type quest just to find them.
Anyway, this article came MINUTES after I was just putting the final touches to a CMS (Content Management Site). At least it’s good to know that I did everything right.
Now, it’s Miller Time!
posted at 01:24 am on April 12, 2002 by Ivan Wilson