Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

<!DOCTYPE>

The document type declaration: tells the browser the page is written in modern HTML.

Syntax

<!DOCTYPE html>

Examples

The first line of every page:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Home</title>
  </head>
  <body>
    <p>The page starts with the doctype.</p>
  </body>
</html>

Notes

It is not a tag but an instruction for the browser, so it has no closing part. Case does not matter: <!doctype html> works too. Without it the browser switches to "quirks mode" for old pages, and layout can behave unexpectedly — for example, box sizes are calculated differently.

See also

  • <html> — The root element of the page: `<head>` and `<body>` live inside it.
  • <head> — The service part of the page: encoding, tab title, linked styles and scripts.
  • <body> — The visible part of the page: everything the user sees.

Related recipes

In the tutorial

  • Document structure — The skeleton of an HTML page — doctype, html, head and body, the encoding, the tab title, viewport and your first index.html file.

Thanks for reading!

Donate to the site — we work hard for you.