In this article, we will discuss the doctype in HTML5. This is a very basic yet important tag in HTML. This is like the heart of HTML. This tag doesn’t have much content and it won’t be a matter of time to finish it. Let’s keep going! Read about Acronym Tag In HTML 5


We may have seen that every HTML document starts with the doctype tag and we may be unsure what it does. We may think this tag doesn’t have any use. If that’s what is on your mind, I guess you are wrong.


All HTML documents must start a with <!DOCTYPE> declaration. The declaration is not an HTML tag. It is an “information” to the browser about what document type to expect.

This is also known as Document Type Declaration. It specifies the HTML version we use. A DOCTYPE declaration appears at the top of a web page before all other elements

According to HTML standards, every HTML document must have specification about the version specification and type. Doctype does this work.

Declaration of Doctype

It is mandatory to write the doctype at the top of the HTML document.



<!doctype HTML>

NOTE: This declaration is only for HTML5 and other version declarations are longer.

Points to be noted

  • Note that, this tag is case insensitive.
  • We saw that it is mandatory to have a version specification. Only when the Doctype is declared, the browser understands that the HTML document is in standard mode. Otherwise, the browser goes into the quirky mode.
  • If we don’t use this tag, we may not get the intended output. This is the reason why you should declare this tag.
  • Doctype tag doesn’t have an end tag.
  • This is also like the parent tag of every tag in the document present and all other tags are child tags.

Browser Support

The browser that supports are,

  1. Chrome
  2. Opera
  3. Safari
  4. Edge
  5. Internet Explorer
  6. Firefox
  7. Android

Layout of HTML

<!DOCTYPE html>
...(HTML heading)
...(code for your webpage)


<!DOCTYPE html>




doctype in HTML5-op
Output sample

Related points

  1.  The doctype declaration refers to a Document Type Definition (DTD). It is an instruction to the web browser about what version of the markup language the page is written in. The World Wide Web Consortium (W3C) provides DTDs for all HTML versions.
  2. You Must add a doctype declaration when creating an HTML document. Also, use the W3C’s validator to check your HTML for markup or syntax error before publishing online.

Frequently Asked Questions(FAQ):

1. Which doctype is correct for HTML5?

HTML5 has only one doctype and its declaration is

2. How many doctypes are present?

HTML5 version has only one doctype.
HTML4 version has three types namely- strict, transitional and frameset


In this article, we discussed the doctype in the HTML5 version. I hope now you understand the importance of this tag. We also discussed the browser supports and other key points related to the doctype. Hope this article helped. Keep learning and happy coding!

Leave a Comment

Your email address will not be published. Required fields are marked *