--- title: "The HTML doctype" category: foundations status: required url: https://webspecification.com/spec/foundations/doctype/ updated: "2026-07-09T00:00:00.000Z" sources: - title: "HTML Living Standard — The DOCTYPE" url: "https://html.spec.whatwg.org/multipage/syntax.html#the-doctype" publisher: "WHATWG" - title: "MDN — Doctype" url: "https://developer.mozilla.org/en-US/docs/Glossary/Doctype" publisher: "MDN" - title: "MDN — Quirks Mode and Standards Mode" url: "https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode" publisher: "MDN" source_repo: undefined licence: CC-BY-4.0 --- # The HTML doctype > Every HTML document must start with as its first line. This opts the browser into standards mode; without it, you get quirks mode and broken layout. ## What it is The doctype is a short declaration at the very top of an HTML document that tells the browser which rendering mode to use. In modern HTML, there is exactly one correct form: ```html ``` It is case-insensitive, so `` is equally valid. It must be the first thing in the document, before ``, with no whitespace, comments, or byte-order mark trickery in front of it. Despite how it looks, the doctype does not declare a version of HTML. The old `HTML 4.01 Transitional` and `XHTML 1.0 Strict` doctypes pointed at a DTD, so reading them as "this document is written in that version" was fair. `` carries no version and switches on no "HTML5 mode". The modern elements and features you may use do not depend on it: `
`, `