QA
Beginner LevelHTML & Semantic Web

What is <!DOCTYPE html> and what happens if it is omitted?

❓ Interview Prompt: Why must <!DOCTYPE html> be placed at the very top of an HTML document? What is Quirks Mode?

'<!DOCTYPE html>' is a required preamble in HTML5 that instructs web browsers to render the document in Standard Mode conforming to modern W3C specifications.

What happens when omitted?

If omitted or placed after comments/markup, browsers switch to Quirks Mode. In Quirks Mode, browsers emulate non-standard rendering behaviors of legacy 1990s browsers (such as Internet Explorer 5), causing:

1
Broken box-model calculations (width including padding/border unexpectedly).
2
Inconsistent line height and font sizing inherits.
3
Unpredictable CSS Layout behavior across Chrome, Firefox, and Safari.

Code Implementation Example

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Standard Mode Document</title>
</head>
<body>
  <h1>Browser in Standard Rendering Mode</h1>
</body>
</html>
💡Standard HTML5 boiler declaration ensuring Standard Mode.
🎯 Interview Key Takeaway

Always place <!DOCTYPE html> as the absolute first line of code to enforce modern browser Standard Mode rendering.

#DOCTYPE#Quirks Mode#Standards#Beginner
Back to all HTML & Semantic Web Questions→

More HTML & Semantic Web Interview Questions

Beginner LevelHTML & Semantic Web

What is Semantic HTML and why is it essential for modern web applications?

Beginner LevelHTML & Semantic Web

What is the difference between inline and block-level HTML elements?

Beginner LevelHTML & Semantic Web

Why is the img alt attribute essential for accessibility and SEO?