Skip to the page
html reference · document

HTML <!DOCTYPE html>

closing tag
n/a — declaration
void element
n/a
lives inside
nowhere — comes before <html>
typically holds
n/a

Where it goes

The very first line of the file. Nothing goes before it, not even a blank line.

Example

<!DOCTYPE html>
<html>
  ...
</html>

Open this example in the editor →

Common mistakes

  • Leaving it out. The page still shows, but spacing and sizes can behave differently in each browser. That old behavior is called quirks mode.
  • Using an old long version from HTML 4. Modern HTML only needs the short <!DOCTYPE html>.

Related

Updated 24 October 2026. Practice it in the html route, or read more on MDN.