HTML - doctype

About

The doctype is the first line of a xml document that defines its type.

Html doctype

For a html document, it's:

<!DOCTYPE html>

Parser may require an EOL character

Mandatory

It's mandatory otherwise the browser will turn into quirks mode 1) and some library will not work as expected 2).

How to check?

Lighthouse

If you do a lighthouse check, it's also reported.

Lighthouse Doctype Mandatory

Javascript console

With javascript, you can check the mode with the compat mode

console.log(document.compatMode)

If its value is:

  • BackCompat, the document is in quirks mode.
  • CSS1Compat, it isn't





Discover More
Card Puncher Data Processing
XML - doctype

doctype is a DTD schema definition. It MUST appear before the first element in the document. The HTML doctype: Example of attribute declarations ...



Share this page:
Follow us:
Task Runner