1

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.

Joonas Pulakka
  • 326
  • 1
  • 2
  • 7

1 Answers1

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 :)

Chris Bier
  • 121
  • 4
  • Yes, that's the point of doctype definition. But I was asking about the – Joonas Pulakka Sep 13 '09 at 14:11
  • 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: http://www.w3.org/TR/xhtml1/#strict . Apparently it's better *not* to use it: http://www.456bereastreet.com/archive/200904/using_an_xml_declaration_triggers_quirks_mode_in_ie_6/ – Joonas Pulakka Sep 13 '09 at 16:23