Headings Hierarchy
Use proper heading levels (h1-h6) to create a logical document outline that screen reader users can navigate.
The Bad (Inaccessible)
<div class="page">
<p class="large-text bold">Welcome to Our Store</p>
<p class="medium-text bold">Featured Products</p>
<div class="product">
<p class="small-text bold">Wireless Headphones</p>
<p>Premium audio experience.</p>
</div>
<p class="large-text bold">About Us</p>
</div>
Accessibility-Ready Code
<main>
<h1>Welcome to Our Store</h1>
<section>
<h2>Featured Products</h2>
<article>
<h3>Wireless Headphones</h3>
<p>Premium audio experience.</p>
</article>
</section>
<section>
<h2>About Us</h2>
<!-- content -->
</section>
</main>
main
h1 Welcome to Our Store
section
h2 Featured Products
article
h3 Wireless Headphones
p Premium audio experience.
section
h2 About Us
// content
<main>
<h1>Welcome to Our Store</h1>
<section>
<h2>Featured Products</h2>
{products.map((product) => (
<article key={product.id}>
<h3>{product.name}</h3>
<p>{product.description}</p>
</article>
))}
</section>
<section>
<h2>About Us</h2>
{/* content */}
</section>
</main>
<main>
<h1>Welcome to Our Store</h1>
<section>
<h2>Featured Products</h2>
<article v-for="product in products" :key="product.id">
<h3>{{ product.name }}</h3>
<p>{{ product.description }}</p>
</article>
</section>
<section>
<h2>About Us</h2>
<!-- content -->
</section>
</main>
<main class="max-w-4xl mx-auto px-6 py-12">
<h1 class="text-4xl font-bold text-slate-900 mb-8">
Welcome to Our Store
</h1>
<section class="mb-12">
<h2 class="text-2xl font-semibold text-slate-800 mb-6">
Featured Products
</h2>
<article class="bg-white rounded-xl p-6 shadow-sm">
<h3 class="text-xl font-medium text-slate-700 mb-2">
Wireless Headphones
</h3>
<p class="text-slate-600">Premium audio experience.</p>
</article>
</section>
<section>
<h2 class="text-2xl font-semibold text-slate-800 mb-6">
About Us
</h2>
</section>
</main>
The Standard
Headings (<h1> through <h6>) create a document outline that screen reader users navigate like a table of contents. Skipping levels or using styled text instead breaks this navigation.
WCAG Criteria
- 1.3.1 Info and Relationships (Level A): Structure must be programmatically determinable.
- 2.4.1 Bypass Blocks (Level A): Headings help users skip to content sections.
- 2.4.6 Headings and Labels (Level AA): Headings must describe their section.
β The Bad (Inaccessible)
Whatβs Wrong?
- No Semantic Headings: Screen readers cannot build a page outline from styled
<p>tags. - No Navigation: Users cannot jump between sections using heading shortcuts.
- βHβ Key Useless: Screen reader users press βHβ to jump to headingsβthis fails completely.
β The Good (Accessibility-Ready Code)
Why This Works
- Clear Hierarchy:
h1 > h2 > h3creates a logical tree structure. - Quick Navigation: Screen readers list all headings in order for easy jumping.
- Single
<h1>: Each page has one main titleβthe page topic.
Accessibility Checklist
- Use exactly one
<h1>per page for the main title. - Never skip heading levels (e.g.,
h1βh3). - Use headings to introduce sections, not for styling.
- Ensure heading text describes the section content.
- Test with a screen readerβs heading navigation (press βHβ).
<main>
<h1>Page Title</h1>
<section>
<h2>Section Level 1</h2>
<article>
<h3>Subsection Level 2</h3>
</article>
</section>
</main>
Technical Deep Dive
The Accessibility Tree
Heading Level 1: "Welcome to Our Store"
βββ Heading Level 2: "Featured Products"
β βββ Heading Level 3: "Wireless Headphones"
βββ Heading Level 2: "About Us"
Screen Reader Behavior
- βHβ Key: Jumps to next heading at any level.
- β1-6β Keys: Jump to specific heading levels (e.g., press β2β for next
<h2>). - Rotor/Elements List: Displays all headings in a navigable list.
Interactive Behavioral Lab
Interactive Sandbox
π¬ Technical Internals
Understand how this component is processed by the browser and Assistive Technology (AT). This section bridges the gap between visual code and the hidden logic that powers accessibility.
π² Accessibility Tree
The data structure used by screen readers to "see" your page. It translates HTML roles and attributes into standardized objects.
βοΈ Event Logic
Expected behavioral standards for keyboard navigation and state transitions. Crucial for users who don't use a mouse.
- Focus: Highlights via
:focus-visible - Activation: Responds to
EnterandSpace - Role: Identified as
Heading Pattern