Missing DOCTYPE Declaration
The <!DOCTYPE html> declaration must be the very first line of your HTML document. It tells the browser to render the page in standards mode. Without it, browsers fall back to 'quirks mode' — a legacy rendering mode where CSS box model, margins, table layouts, and other rules behave differently.
Why It Matters
Quirks mode causes inconsistent rendering across browsers. Elements may have different default margins, the box model changes how width/height are calculated, and some CSS properties behave unexpectedly. It's a common cause of 'works on my browser but not others' bugs.
Code Examples
<html> <head> <title>My Page</title> </head>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>My Page</title> </head>
How to Fix
- 1Add <!DOCTYPE html> as the very first line — before any whitespace or comments.
- 2Use the HTML5 doctype: <!DOCTYPE html> (not the older XHTML or HTML4 doctypes).
- 3The doctype is case-insensitive: <!doctype html> works too.
- 4Check that no BOM (byte order mark) or whitespace appears before the doctype.
Check Your HTML Now
Our validator detects this error automatically and shows the exact line number.
Open HTML ValidatorHostinger — Fast & Affordable Web Hosting
Deploy clean, validated HTML on reliable hosting.
Related HTML Errors
Missing Lang Attribute
Learn why the lang attribute on the html element is critical for screen readers, translations, and SEO.
Missing Viewport Meta Tag
Why the viewport meta tag is essential for responsive design. Fix mobile rendering issues with the correct viewport configuration.
Missing Charset Declaration
Why declaring charset UTF-8 is essential and how missing charset causes encoding issues and garbled text.