HTML <!DOCTYPE> Declaration
The <!DOCTYPE> declaration specifies the HTML version used in the document. Learn how to use <!DOCTYPE> Declaration with with syntax and examples.
The <!DOCTYPE> declaration is the first line of code in an HTML or XHTML document. It specifies the HTML version used in the document. Each HTML document should start with this declaration so browsers will render the page in Standards Mode instead of Quirks Mode, ensuring compliance with web standards. In HTML 4.01, this declaration refers to a Document Type Definition (DTD), which specifies the structure and the legal elements of an XML document.
The <!DOCTYPE> is declared before the <html> tag. The declaration is not case sensitive.
Syntax
Legacy DTD Syntax
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "https://www.w3.org/TR/html4/strict.dtd"><!DOCTYPE> Parameters
Root element — the parent element that contains all other elements. For HTML it is the <html> tag.
Publicity — indicates if the DTD is PUBLIC or SYSTEM. For HTML/XHTML, the value is PUBLIC.
Registration — historically indicated ISO registration status (+ or -). For W3C DTDs, this is typically omitted.
Organization — the name of the DTD developer. For HTML/XHTML, this is W3C.
Type — the type of the document. For HTML/XHTML, the value is DTD.
Name — unique identifier describing the DTD.
Language — the language of the document (two uppercase letters). For HTML/XHTML, this is typically EN.
URL — the URL of the document type description (e.g., https://www.w3.org/TR/html4/strict.dtd).
Types of the <!DOCTYPE> Declaration for HTML
Modern HTML documents use a single, simplified declaration. Legacy HTML 4.01 had three types:
HTML5
<!DOCTYPE html>Strict - contains all HTML elements and attributes. However, presentational or deprecated elements are not included.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "https://www.w3.org/TR/html4/strict.dtd">Transitional - contains all HTML elements and attributes, including presentational and deprecated elements. Frames are not allowed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">Frameset - is equal to Transitional, but allows the use of frames.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "https://www.w3.org/TR/html4/frameset.dtd">Example of the HTML <!DOCTYPE> declaration:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<h2>Elements example</h2>
<p>This is some paragraph.</p>
<p>This is another paragraph <br /> with line break.</p>
</body>
</html>Result

Types of the <!DOCTYPE> Declaration for XHTML
Here you can find types of the <!DOCTYPE> declaration for XHTML.
XHTML 1.0 Strict
This DTD includes all the HTML elements and attributes, except presentational or deprecated elements. This DTD doesn’t allow frameworks.
<!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 includes all the HTML elements and attributes, as well as presentational and deprecated elements. Framesets are not allowed.
<!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 similar to XHTML 1.0 Transitional, but framesets are allowed.
<!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 equal to XHTML 1.0 Strict, but allows adding modules (e.g., to provide Ruby support for East-Asian languages).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">Practice
Which of the following statements about HTML DOCTYPE declaration are correct?