Best Practices Small
Add an HTML5 doctype
The <!DOCTYPE html> declaration tells the browser to render the page in standards mode, following the CSS and HTML specifications consistently. Without it (or with an outdated doctype), browsers fall back to "quirks mode", which reproduces decades-old rendering inconsistencies that can make layout and CSS behave unpredictably across browsers.
Why it matters
Without a doctype, browsers render the page in "quirks mode", which can cause inconsistent layout and CSS behavior across browsers.
How to fix
- 1 Add <!DOCTYPE html> as the very first line of the HTML document, before any whitespace, comments, or XML declaration.
- 2 Validate the page (e.g. with the W3C Markup Validator) to confirm the browser is rendering in standards mode rather than quirks mode.
Common mistakes
- Placing whitespace, comments, or an XML declaration before the doctype, which still triggers quirks mode in some browsers even though a doctype is technically present.
- Assuming a CMS or framework always outputs the doctype correctly, when a custom template or error page might bypass the normal layout wrapper.
- Not noticing quirks-mode rendering differences because the page happens to look fine in one browser during development.
How to verify
- 1 View page source and confirm <!DOCTYPE html> is the very first line, with nothing before it.
- 2 Check the browser's devtools rendering mode indicator (or run the page through the W3C Markup Validator) to confirm standards mode is active.
- 3 Spot-check less common templates (error pages, print stylesheets) that might be generated by a different code path than the main layout.
Related checks
Ready to see where you stand?
Scan your site and get your Engineering Score with a prioritized roadmap in under a minute, no signup required.
EngineeringScore