WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

HTML <!DOCTYPE> Declaration


Example

<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>

<body>
The content of the document......
</body>

</html>
Try it yourself »

<!DOCTYPE> The statement is at the forefront of the document, at <html> Before the label.

<!DOCTYPE> The declaration is not an HTML tag; it is used to tell the Web browser which HTML version is used.

In HTML 4.01,<!DOCTYPE> The declaration needs to refer to DTD (Document Type Declaration) because HTML 4.01 is based on SGML (Standard Generalized Markup Language). The DTD specifies the rules of the markup language to ensure that the browser can render the content correctly.

HTML5 is not based on SGML and does not require a reference to DTD.

Tip: Always add to your HTML documents <!DOCTYPE> Declaration to ensure that the browser knows the document type in advance.


Browser Support

Element
<!DOCTYPE> Yes Yes Yes Yes Yes Yes

Differences Between HTML 4.01 and HTML5

There are three different <!DOCTYPE> declarations in HTML 4.01. In HTML5 there is only one:

<!DOCTYPE html>

HTML Elements and Doctypes

Look at our table of all HTML elements, and what Doctype each element appears in.


Tips and Notes

Tip: The <!DOCTYPE> declaration is NOT case sensitive.

Tip: You can go here to validate if your document is valid HTML.


Common DOCTYPE Declarations

HTML 5

<!DOCTYPE html>

HTML 4.01 Strict

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

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

HTML 4.01 Transitional

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

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

HTML 4.01 Frameset

This DTD is equal to HTML 4.01 Transitional, but allows the use of frameset content.

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

XHTML 1.0 Strict

This DTD contains all HTML elements and attributes, but does not include presentational or outdated elements such as font. Framesets are not allowed. The structure must be written in XML in a standard format.

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

XHTML 1.0 Transitional

This DTD contains all HTML elements and attributes, including presentational or outdated elements (such as font). Framesets are not allowed. The structure must be written in XML in a standard format.

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

XHTML 1.0 Frameset

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

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

XHTML 1.1

This DTD is the same as XHTML 1.0 Strict, but allows you to add modules (such as Ruby support for East Asian languages).

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