Document Type Declaration
Categories: Software stubs | XML-based standards
A Document Type Declaration, or DOCTYPE, associates a particular SGML or XML document with a Document Type Definition (DTD). In the serialized form of the document, it manifests as a short string of markup that conforms to a particular syntax.
Despite its name, a Document Type Declaration is not suitable for deducing the type of the document, although apparently it was originally supposed to be.
In new browsers for documents served as text/html, the DOCTYPE is used for doctype sniffing in order to choose a layout mode.
Example
A Document Type Declaration can be found in the source code of every Wikipedia page. For example, the first line of many Wikipedia pages reads as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
This Document Type Declaration includes by reference a DTD, whose public identifier is -//W3C//DTD XHTML 1.0 Transitional//EN and whose system identifier is http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd. An entity resolver may use either identifier for locating the referenced external entity. The root element is declared to be html.
See also
- Document Type Definition contains an example
- Article on Doctypes from A List Apart.