</>
ValidateHTML

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

❌ Invalid
<html>
<head>
  <title>My Page</title>
</head>
✓ Valid
<!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 Validator
Recommended

Cloudways · Managed Cloud Hosting

Fix this HTML error, then deploy on Cloudways managed cloud (AWS, GCP, DigitalOcean). 20% off 3 months with code VALIDATEHTML.

Start free trial

Related HTML Errors

← View all HTML errors