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:



HTML 4.01 Transitional Document:

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


HTML 4.01 Frameset Document:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 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"


XHTML 1.1:



Example: DOCTYPE for HTML5

<!DOCTYPE html>




<body >



Document Type Note:

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


Top Technologies