Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

<?xml version="1.0" encoding="utf-8"?>

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.