You are here:

  1. Manual
  2. Development
  3. Page structure
  4. DocType declaration

Page structure: The DocType Declaration

On each HTML page a DocType Declaration, or Document Type Definition (DTD), must precede the ‘html’ tag. The DocType provides the browser with information on the HTML type used to code the page. This information is important for three reasons:

  • Display by browsers: The most popular browsers have two modes: 'Quirks' mode and 'Standards compliance' mode. 'Quirks' mode is activated by HTML documents with old, erroneous or absent DocTypes. This mode emulates the 'buggy' behaviour of old browsers. HTML documents with correct DocTypes activate 'Standards' mode: the browser behaves more in compliance to the W3C specifications.
  • Validators: An HTML 'validator' controls the correctness of the HTML syntax on the basis of the indicated DocType.
  • Editors: Many HTML editors (programmes for the HTML production) use the DocType to determine which HTML version is being used.

Each HTML or XHTML document must begin with a valid DocType Declaration.

Guideline R-pd.6.1

If XHTML is used

If XHTML is used for the markup of websites, an XML Declaration can be used for the DocType Declaration.

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

This XML Declaration causes problems with a few browsers, however, varying from reverting to Quirks mode (different display of CSS) to refusal to display the page (a serious accessibility problem). For this reason and because of the fact that an XML Declaration is optional, for the time being its use on government websites is not recommended.

If the XML Declaration is omitted, the document can use no character set other than UTF-8 or UTF-16. See Character encoding for further information on character sets and the use of UTF-8.

In short, if XHTML is used, do not use an XML Declaration and use UTF-8 as the character set.


Web Guidelines version 1.3, November 2007.