HTML DOCTYPE Tutorial

In this section, we will see what document types are as well as explain away the <!DOCTYPE> element.

Document Type in HTML: What is <!DOCTYPE> Tag?

Browsers are capable of interpreting many types of documents and display them to users to see.

Just to mention a few of these types, we can call: HTML 4, XHTML, and HTML5.

When a document is sent to a browser, we need to declare the type of that document to the browser as well, so that it knows how to interpret it and display the result for users to see.

This is where <!DOCTYPE> Element comes in!

This Element is a signal or basically information to the browser that the incoming document is basically of type “X” where “X” is the type we declare inside this element, and any interpretation of the document should be based on the consideration that the type is “X”.

So it is necessary to put this tag at the beginning of your document and set the type in it if you want your document to be translated in a right way by the browsers.

<!DOCTYPE> Tag Syntax:

<!DOCTYPE type-of-the-document>

<!DOCTYPE> Tag Values

There are different values the can be set as the value of the <!DOCTYPE>.

In the list below, you can see these values:

HTML5 Document:

<!DOCTYPE html>

HTML 4.01 Strict Document:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

HTML 4.01 Transitional Document:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

HTML 4.01 Frameset Document:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"

"http://www.w3.org/TR/html4/frameset.dtd">

XHTML 1.0 Strict:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML 1.0 Transitional:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML 1.0 Frameset:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

XHTML 1.1:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Example: DOCTYPE for HTML5

<!DOCTYPE html>

<html>

<head>

</head>

<body >

</body>

</html>

Document Type Note:

The <!DOCTYPE> Element is not an HTML Tag! It’s basically an informational element designed to help browsers interpret documents correctly.

Leave a Reply