!DOCTYPE

The   declaration should be the very first thing in an HTML document, before the  tag. This declaration is not an HTML element; it is an instruction to the web browser about what version of the markup language the page is written in and it refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup language, so that the browsers can render the content correctly.

Here are the examples for modern HTML versions that follow, with the most-recommended first:

(X)HTML5
This DTD works for HTML5, including the XML flavor (XHTML5). This is what it looks like in the source code:

XHTML 1.1
This DTD is the same as XHTML 1.0 Strict, but allows you to add modules (ex. to provide ruby support for East-Asian languages).

XHTML 1.0 Strict
This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like ). Framesets are not allowed. The markup must also be written as well-formed XML.

XHTML 1.0 Transitional
This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like ). Framesets are not allowed. The markup must also be written as well-formed XML.

XHTML 1.0 Frameset
This DTD is the same as XHTML 1.0 Transitional, but allows the use of frameset content.

HTML 4.01 Strict
This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like ). Framesets are not allowed.

HTML 4.01 Transitional
This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like ). Framesets are not allowed.

HTML 4.01 Frameset
This DTD is the same as HTML 4.01 Transitional, but allows the use of frameset content.