Take the 2-minute tour ×

W3C DTD instructions include the following as the very first line of a (X)HTML document:


I acknowledge the importance of the DOCTYPE declarations that come after this, but what exactly is the point of this first line? Do I need it? W3C validator doesn't seem to care whether it's there or not.

share|improve this question
add comment

1 Answer

Its part of specifying what mark up language you have used. When web browsers have to guess, they go into strict mode where the expect you to code the page as specified by the w3c standards.

Without a doctype the browser will go into "quirks mode" which means they might not render the page the way you wish. Also, in general, its just good practice :)

share|improve this answer
Yes, that's the point of doctype definition. But I was asking about the <?xml version... line. I just checked about dozen random webpages, and while almost all define the doctype, no site so far seems to include that curious <?xml... line. –  Joonas Pulakka Sep 13 '09 at 14:11
The <?xml line is a doctype :P –  Chris B Sep 13 '09 at 15:02
Humm, actually it's an "XML declaration", and although it's recommended, it's not required if UTF-8 or UTF-8 charset is used: w3.org/TR/xhtml1/#strict . Apparently it's better not to use it: 456bereastreet.com/archive/200904/… –  Joonas Pulakka Sep 13 '09 at 16:23
add comment

Your Answer


