HTML Tags

HTML <!DOCTYPE HTML> Tag

The <!DOCTYPE html> declaration tells the browser which version of HTML the page uses and must be the very first thing in an HTML document.


What is the <!DOCTYPE html> declaration?

The <!DOCTYPE> is not an HTML tag; it is an instruction to the web browser about what version of HTML the document is written in. In HTML5 the declaration is deliberately short and version-less. It must appear once, at the top of the page, before the <html> element.

Its main job is to make browsers render the page in standards mode. If the declaration is missing, browsers fall back to quirks mode, emulating legacy behaviour that can break modern CSS layout and box-model calculations.

Syntax

The HTML5 doctype is case-insensitive and takes no attributes.
<!DOCTYPE html>

Complete example

A minimal, valid HTML5 document.
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>My First Page</title>
  </head>
  <body>
    <h1>Hello, world!</h1>
  </body>
</html>
⚠️

Always place <!DOCTYPE html> as the first line. Even a blank line or comment before it can trigger quirks mode in some browsers.

Older HTML 4.01 and XHTML doctypes were long and referenced a DTD (Document Type Definition), for example <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">. HTML5 removed the DTD requirement, which is why the modern declaration is so short.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships