Anne van Kesteren

XML Declaration, not Prolog

Chris Bentley sent me an e-mail yesterday about my little CSS box model write up. Where I stated that you can put Internet Explorer into quirks mode by using a XML Prolog before the DOCTYPE I should have said XML Declaration. The difference is easy. Everything before the root element is part of the XML Prolog (or SGML Prolog, if you are sending your document as text/html). That includes the XML Declaration, comments, processing instructions and the DOCTYPE. The XML Declaration is often referred to as Prolog, which is incorrect. The XML Declaration looks like:

<?xml version="1.0"?>

An XML Prolog can look like:

<?xml version="1.0"?>
<?xml-stylesheet href="screen.xslt" type="application/xml" media="screen"?>
<!-- foo -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">

Note that this does not include any elements at all. For valid documents, an XML Prolog is required (the DOCTYPE) and an XML Declaration is not.

Comments

  1. Just a minor detail: The XML declaration is not a processing instruction. It may look like it, but it's in fact just an XML declaration. This can easily be seen if you look at the PITarget construct, which explicitly excludes [xX][mM][lL]. There are some who call the XML declaration for a pseudo-PI, though.

    Posted by liorean at

  2. Thanks, fixed.

    Posted by Anne at