DOCTYPE
A doctype, or document type declaration, is a marker placed at the top of a markup document to declare the document type and the version of the markup language being used. It helps user agents such as web browsers decide how to parse and render the content and, in older systems, which formal grammar to apply for validation. The doctype is not an element of the document’s content; it is a preface that appears before the root element.
In HTML, doctypes historically pointed to a Document Type Definition (DTD) to enable standards-compliant rendering. Modern
Placement and scope vary by language. In HTML and XHTML, the doctype sits at the very top
Doctype behavior is connected to rendering modes. A missing or incorrect doctype can cause a document to
- HTML 4.01 Strict: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- XHTML 1.0 Strict: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">