HTML5 Reference

HTML5 <!DOCTYPE> declaration

Definition

The <!DOCTYPE> declaration lets the browser know which version of HTML/XHTML we are using.

The <!DOCTYPE> declaration must be located at the top of a HTML document and before any HTML tags as shown in the example below.

The <!DOCTYPE> declaration is commonly referred as the document type declaration (DTD).

Example


<!DOCTYPE html>   <!-- The DOCTYPE declaration always comes first in a HTML document --> 

<html lang="en">
<!-- Everything else goes between the start and end HTML tags. --> 

<head>
<!-- The header contains meta information pertaining to the HTML document as well 
as a title and other stuff we will discuss in HTML Intermediate/Advanced lessons.
External files such as CSS stylesheets and JavaScript files are also imported in
the header section of our HTML file. -->
  <title>A Title which will appear in the Windows title bar.</title>
</head>

<body>
<!-- The content of the web page appears in the body section. -->
</body>

<!-- We complete the HTML file with the closing HTML tag. -->
</html>

HTML/XHTML Doctypes available from W3C Recommendations older standards

HTML 4.01

Contains all HTML 4.01 elements.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"  
         "https://www.w3.org/TR/html4/loose.dtd"> 

Use this if for some strange reason you want to use frames and you still believe in the tooth fairy.
Not Recommended.

XHTML 1.0 Frameset

Contains all HTML 4.01 elements.
Framesets are allowed by this DTD.


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

Use this if for some strange reason you want to use frames and you still believe in the tooth fairy.
Not Recommended.

XHTML 1.0 Transitional

Contains all HTML 4.01 elements INCLUDING deprecated and presentational elements.
Framesets are not allowed by this DTD.


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

Generally used for legacy code where deprecated elements are still used.

XHTML 1.0 Strict

Contains all HTML 4.01 elements EXCLUDING deprecated and presentational elements.
Framesets are not allowed by this DTD.


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

For XHTML this is supported in all browsers.
Recommended.

XHTML 1.1

Contains all HTML 4.01 elements EXCLUDING deprecated and presentational elements.
Framesets are not allowed by this DTD.
Allows the use of modules.


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

The latest version of XHTML, but not supported in all browsers.

Relevant HTML Tutorials

HTML Basics - HTML Structure - Document