w3docs logo

HTML <!DOCTYPE> Declaration

The <!DOCTYPE> declaration is the first line of the code in HTML or XHTML document. It specifies the HTML version used in the document. Each HTML document should start with this declaration: so the browsers will render the page compliant with HTML 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.


[Root element] [Publicity] "[Registration]//[Organization]//[Type] [Name]//[Language]" "[URL]">

<!DOCTYPE> Parameters

Root element — a parent element that contains all the other elements. For HTML it is the <html> tag.

Publicity — the document can be PUBLIC or SYSTEM (local files, for example). For HTML/XHTML the value is PUBLIC.

Registration - can have two values: plus (+) - the developer is registered in ISO (International Organization for Standardization) and - (minus) - the developer is not registered. For W3C, the value is set to "-".

Organization — the name of DTD developer. The developer of HTML/XHTML is W3C, and its name is declared in <!DOCTYPE>.

Type — the type of the document. For HTML/XHTML the value is DTD.

Name — unique identifier describing DTD.

Language — the language of the document (two letters in uppercase). For HTML/XHTML the language is English (EN).

URL — the URL of the document type description (e.g. https://www.w3.org/TR/html4/loose.dtd).

Types of the <!DOCTYPE> Declaration for HTML

There are three types of the <!DOCTYPE> declaration for HTML:

Strict - contains all HTML elements and attributes. However, the 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">

There is only one version of declaration for HTML 5.

<!DOCTYPE html>

Example of the HTML <!DOCTYPE> declaration:

<!DOCTYPE html>
    <title>Title of the document</title>
    <h2>Elements example</h2>
    <p>This is some paragraph.</p>
    <p>This is another paragraph <br/> with  line break.</p>



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">


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">

Browser support

chrome edge firefox safari opera
Do you find this helpful?