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.
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