HTML - <!DOCTYPE> Declaration



The HTML <!DOCTYPE> declaration, is a component of the HTML document used to inform the web browser about the HTML version and document type it should use for rendering the page.

Although it is not an HTML tag, but it must be first line in the document, prior to any HTML elements to ensure proper describing and display of the web pages.

As the HTML <!DOCTYPE> declaration is not a case sensitive, So we can declare the version as we want.

<!DOCTYPE html>
<!DocType html>
<!Doctype html>
<!doctype html>

Declaration for Different Version

The current version of HTML is 5, and in this tutorial we will learn all the things around HTML5. In HTML 4.01 or older, the declaration is more complicated because it must refer to a DTD (document type definition). A DTD defines the structure and legal elements of an XML document. In contrast, the DOCTYPE declaration is easier in HTML5 because it no longer requires a reference to the DTD. It is no longer based on SGML.

Try to click the icon run button run button to run the following HTML code to see the output.

HTML5 <!DOCTYPE> Declaration

Let's look at the following example, where we are going to use the <!DOCTYPE> declaration in the HTML5.

<!DOCTYPE html>
<html>
<head>
    <title>HTML5 Example</title>
</head>
<body>
    <p>Welcome</p>
</body>
</html>

HTML 4.01 Strict

Consider the following example, where we are going to declare the HTML 4.01 Strict, which excludes the deprecated tags and attributes.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>HTML 4.01 Strict declaration</title>
</head>
<body>
    <p>Hello, this is an example for HTML 4.01 Strict declaration .</p>
</body>
</html>

HTML 4.01 Transitional

In the following example, We are going to declare the HTML 4.01 Transitional, that supports the older, deprecated tags for transitional purposes.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>HTML 4.01 Transitional declaration</title>
</head>
<body>
    <p>Welcome to TutorialsPoint.</p>
</body>
</html>

DOCTYPE declaration in HTML 4.01 Frameset

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

DOCTYPE declaration in XHTML 1.0 Strict

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

DOCTYPE declaration in XHTML 1.0 Transitional

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

DOCTYPE declaration in XHTML 1.0 Frameset

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

DOCTYPE declaration in XHTML 1.1

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

Supported Browsers

Tag Chrome Edge Firefox Safari Opera
!DOCTYPE Yes Yes Yes Yes Yes
html_tags_reference.htm
Advertisements