DEV Community

Srijan
Srijan

Posted on • Originally published at hackinbits.com

What is the purpose of <!DOCTYPE html> at starting of an HTML document?

This post is first published on hackinbits.com.

Doctype is required in HTML document for legacy reasons. Its main purpose is to prevent the browser from entering 'Quirks Mode' while rendering the document.

Including the DOCTYPE in a document ensures that the browser makes the best-effort to follow standard specifications. The doctype should be included at the beginning of the HTML document as shown in the example, below.

<!DOCTYPE html>
<html>
  <head>
    <title>Including Doctype in HTML Document</title>
  </head>
  <body>
    <h1>
      Including Doctype in HTML Document
    </h1>
    <p>
      Welcome to hackinbits.com
    </p>
   </body>
</html>
Enter fullscreen mode Exit fullscreen mode

In HTML5, Doctype's only purpose is to activate the full standard mode.

Top comments (0)

Heroku

The AI PaaS for deploying, managing, and scaling apps.

Heroku tackles the toil — patching and upgrading, 24/7 ops and security, build systems, failovers, and more. Stay focused on building great data-driven applications.

Get Started

Announcing the First DEV Education Track: "Build Apps with Google AI Studio"

The moment is here! We recently announced DEV Education Tracks, our new initiative to bring you structured learning paths directly from industry experts.

Dive in and Learn

DEV is bringing Education Tracks to the community. Dismiss if you're not interested. ❤️