Next.js fix

Before and after

Broken — before
// app/components/SiteFooter.tsx (Broken: <h4> inside global layout skips h2 & h3)
export function SiteFooter() {
  return (
    <footer>
      <section>
        <h4 className="text-sm font-semibold">Resources</h4>
        <ul>
          <li><a href="/rules">WCAG 2.2 Rules Catalog</a></li>
        </ul>
      </section>
    </footer>
  );
}
Fixed — after
// app/components/SiteFooter.tsx (Fixed: semantic <h2> with compact visual typography)
export function SiteFooter() {
  return (
    <footer>
      <section>
        <h2 className="text-sm font-semibold text-slate-900">Resources</h2>
        <ul>
          <li><a href="/rules">WCAG 2.2 Rules Catalog</a></li>
        </ul>
      </section>
    </footer>
  );
}
Live preview

Fixed vs. broken example

Passes heading-order
Accessibility tree: Sequential outline: heading level 1 -> heading level 2 (clean hierarchy)

Decouple visual typography from semantic heading depth: choose <h1>–<h6> strictly for document outline nesting and apply CSS utility classes for font size.

Automated test

Playwright + axe-core check

tests/a11y-heading-order.spec.ts
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";

test("Next.js App Router pages & MDX docs pass heading-order", async ({ page }) => {
  await page.goto("/rules/color-contrast/tailwind");
  const results = await new AxeBuilder({ page })
    .withRules(["heading-order"])
    .analyze();
  expect(results.violations).toEqual([]);
});

Template deduplication tip

A footer component in app/layout.tsx using <h4> headers breaks heading-order on every route that lacks an <h2> and <h3>. Switching footer section titles to <h2 className='text-sm font-semibold'> clears the whole app.

Screen readers

What NVDA and VoiceOver announce

Over 67% of screen-reader users navigate long pages primarily by jumping between headings (H / 1–6 keys). Skipping from <h1> straight to <h4> for visual sizing breaks the mental document outline and makes sub-sections appear orphaned.

NVDA (Windows)

Broken

"Accessibility Audit Report, heading level 1" -> "Key Template Clusters, heading level 4" (user suspects missed sections 2 & 3)


Fixed

"Accessibility Audit Report, heading level 1" -> "Key Template Clusters, heading level 2"

VoiceOver (macOS / iOS)

Broken

"heading level 1, Accessibility Audit Report" -> "heading level 4, Key Template Clusters"


Fixed

"heading level 1, Accessibility Audit Report" -> "heading level 2, Key Template Clusters"

Common questions

Should a Next.js App Router layout render an <h1> in app/layout.tsx?
No—leave <h1> to each leaf page.tsx so every route has its own unique top-level page heading, while shared header/footer landmarks use non-heading brand links and <h2> footer group headings.
How do I prevent MDX authors from skipping headings in Next.js blogs?
Render the frontmatter title as <h1> in your page template, start MDX body headings at ## (<h2>), and run A11yDrift CI checks on preview PRs to catch accidental #### jumps.
Is skipping headings a WCAG 2.2 Level A or AA failure?
axe-core classifies heading-order as a high-value best practice tied to WCAG 1.3.1 Info and Relationships and 2.4.6 Headings and Labels; fixing it dramatically improves NVDA/VoiceOver outline navigation.