Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Lesson 2 of 9
Document Outline & Heading Hierarchy
Learn the rules of heading hierarchy (h1 through h6) and how search engines and screen readers use them to build a document outline. A single h1 per page, proper nesting, and logical structure directly impact SEO rankings.
Heading Hierarchy Rules
Headings create a hierarchical outline of your page. Google and screen readers rely on this outline to understand content structure. Rule 1: One <h1> per page - it should describe the page's main topic. Rule 2: Don't skip levels - go h1 → h2 → h3, never h1 → h3. Rule 3: Headings should summarize the section below them. Rule 4: Use CSS for styling, not heading levels - don't use <h3> just because you want smaller text.
Heading hierarchy defines the document outline used by search bots and screen readers
Document Outline Example
<!-- Correct heading hierarchy -->
<body>
<header>
<h1>Complete Guide to HTML5</h1> <!-- Page title (only one h1) -->
</header>
<main>
<section>
<h2>What is HTML5?</h2> <!-- Major section -->
<p>HTML5 is the latest version...</p>
<h3>History of HTML</h3> <!-- Sub-section of "What is HTML5?" -->
<p>HTML was created in 1991...</p>
<h3>HTML5 vs HTML4</h3> <!-- Another sub-section -->
<p>HTML5 introduced semantic elements...</p>
</section>
<section>
<h2>Semantic Elements</h2> <!-- Another major section -->
<h3>Structural Elements</h3> <!-- Sub-section -->
<h4>The header Element</h4> <!-- Sub-sub-section -->
<h4>The nav Element</h4>
<h3>Text-Level Elements</h3>
<h4>The time Element</h4>
<h4>The mark Element</h4>
</section>
</main>
</body>
<!-- ❌ WRONG: Skipped heading levels -->
<h1>Page Title</h1>
<h3>This skips h2!</h3> <!-- Don't do this -->
<h5>This skips h4!</h5> <!-- Don't do this -->Tip
Use the W3C Markup Validation Service (validator.w3.org) to check if your heading hierarchy is correct. It will flag skipped heading levels and missing h1 elements. Screen reader users navigate by headings 40% of the time - correct hierarchy dramatically improves their experience.
Quick Quiz: Heading Hierarchy
Finished this lesson?