Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

What are the different kinds of Doctypes available ?

  • Difficulty Level : Expert
  • Last Updated : 28 Nov, 2021

A doctype declaration or document type declaration is information to the browser about what document type should it expect. It is not an HTML tag. All the HTML documents that you code should start with a <!DOCTYPE> declaration.

The doctype declaration is written just above the <html> tag, at the very start of each document you write.

HTML5 doctype: This is the most latest version of the document type currently used. It has no disadvantages and is easier to implement and recall. It will correctly validate all HTML 5 features, as well as most of HTML 4/XHTML 1.0 features.

 

Syntax:

<!DOCTYPE html>

Strict doctype (HTML 4.01): The HTML 4.01 strict doctype validates the written code against the HTML 4.01 spec. However, it doesn’t allow any deprecated elements or presentational markups such as <font> elements, or framesets to be used. It validates loose HTML style markup, for example, minimized attributes and non-quoted attributes (eg required, rather than required=”required”).

Syntax:

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

Transitional doctype (HTML 4.01): The HTML 4.01 transitional doctype also validates the written code against the HTML 4.01 spec, the same as the strict doctype.  It does allow some presentational markup and deprecated elements (such as <font> elements) but not framesets. Just like strict doctype, it also validates loose HTML style markup.

Syntax:

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

Strict and Transitional doctypes (XML 1.0): These are the exact XHTML 1.0 coequals of the HTML 4.01 doctypes we talked about above, so functionally they are the same, except that they won’t validate loose HTML style markup: it all has to be well-formed XML.

Syntax:

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

And

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

Frameset doctypes (HTML 4.01 and XML 1.0): They are functionally the same as HTML 4.01 transitional and XHTML 1.0 transitional independently, but they allow the use of framesets. 

Note: We would suggest that you should avoid using framesets and the frameset doctype. They are outdated and are not used in modern times and coding practices. 

If you want to use framesets and still have your markup validated, you can use one of these two doctypes:

Syntax:

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

And,

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

Other doctypes: There are some more ancient and rare versions of doctypes but they are even more outdated than the frameset doctype. In case you come across any other doctype, that is not mentioned here it is because they are not used anymore. Chances are that the code you find such doctypes is itself written or used in earlier versions.

Example:

HTML




<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>GeeksforGeeks</title>
    </head>
    <body>
        <h2>What are the different kinds of Doctypes?</h2>
    </body>
</html>

Output: 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!