Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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 Bier 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: . Apparently it's better not to use it:… – Joonas Pulakka Sep 13 '09 at 16:23

Your Answer


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.