HTML & CSS Wiki
Advertisement

The <!DOCTYPE> declaration should be the very first thing in an HTML document, before the <html> 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[]

<!DOCTYPE html>

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

XHTML 1.1[]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

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[]

XHTML 1.0 Strict[]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

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

XHTML 1.0 Transitional[]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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


XHTML 1.0 Frameset[]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

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

HTML 4.01[]

HTML 4.01 Strict[]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

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


HTML 4.01 Transitional[]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

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


HTML 4.01 Frameset[]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

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

Advertisement