---
title: Doctype
slug: Glossary/Doctype
tags:
  - Browser
  - CodingScripting
  - DOCTYPE
  - Glossary
  - HTML
  - Intro
---
In {{Glossary("HTML")}}, the doctype is the required "`<!DOCTYPE html>`" preamble found at the top of all documents. Its sole purpose is to prevent a {{Glossary("browser")}} from switching into so-called ["quirks mode"](/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode) when rendering a document; that is, the "`<!DOCTYPE html>`" doctype ensures that the browser makes a best-effort attempt at following the relevant specifications, rather than using a different rendering mode that is incompatible with some specifications.

## See also

- [Definition of the DOCTYPE in the HTML specification](https://html.spec.whatwg.org/multipage/syntax.html#the-doctype)
- [Quirks Mode and Standards Mode](/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode)
- [Document.doctype](/en-US/docs/Web/API/Document/doctype), a JavaScript method that returns the doctype
