HTML Doctypes
Write the doctype used for a modern HTML document.
Understand the topic
The short HTML doctype is a declaration placed before the root element. It tells browsers to use standards mode rather than legacy quirks behavior. It is not an HTML element and does not wrap content. Older HTML versions used longer declarations, but modern HTML authoring normally uses the short form. The doctype does not perform markup validation.
Worked example
<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Standards mode</title></head>
<body><h1>A modern HTML document</h1></body>
</html>
In developer tools, document.compatMode is normally CSS1Compat in standards mode. That name does not mean the page uses an obsolete CSS version.
Practice
Write the doctype used for a modern HTML document.
Show a suggested answer
<!doctype html>Common mistake
Do not copy a complex legacy declaration without a reason or mistake the doctype for a tag requiring an end tag.