You are here: Reference > HTML > tags > !DOCTYPE

!DOCTYPE element

Browser support:
Specifies the Document Type Definition (DTD) for the document.
Each HTML and XML document can have only one !DOCTYPE element and it must be placed before the root element (the html element in HTML documents) of the document. The DTD specifies the syntax of the document and affects the visual appearance of the page.
<!DOCTYPE RootElement Availability "URI" [declarations]>
parts of DOCTYPE Available values
RootElement Specifies the top-level element of the document
HTML - Normal HTML document.
Availability Specifies whether the FPI (formal public identifier) is a system resource or open to the public.
PUBLIC - Open to the public.
SYSTEM - Private system resource.
URI The URI of the DTD. For example, "-//W3C//DTD HTML 4.01//EN".
declarations Specifies the location or the declaration of entities and elements used to parse the document.
For example, "".
Commonly used document types: Excluding special cases, the use of the HTML5 document type is recommended.
Document type Declaration
XHTML 1.1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
XHTML 1.1 Strict <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Strict//EN" "">
XHTML 1.1 Transitional <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "">
XHTML 1.1 Frameset <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Frameset//EN" "">
XHTML 1.0 Strict <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
XHTML 1.0 Transitional <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
XHTML 1.0 Frameset <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "">
HTML 4.01 Strict <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "">
HTML 4.01 Transitional <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
HTML 4.01 Frameset <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "">
If you want to see the HTML tags by categories, please visit this page.
This element cannot have a closing tag.
JavaScript page for this element: doctype.

Example HTML code 1:

This example shows how to set the character encoding of the document in HTML5:
<!DOCTYPE html>
    <meta charset="utf-8" />
Did you find this example helpful? yes no

Example HTML code 2:

This example shows how to set the character encoding of the document in document types other than HTML5:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Did you find this example helpful? yes no

External links:

User Contributed Comments

Post Content

Post Content