WordPress fix

Before and after

Broken — before
<?php // functions.php (Broken: sidebar widget titles jump directly to <h4>)
register_sidebar( array(
  'name'          => __( 'Blog Sidebar', 'mytheme' ),
  'id'            => 'sidebar-1',
  'before_title'  => '<h4 class="widget-title">',
  'after_title'   => '</h4>',
) );
Fixed — after
<?php // functions.php (Fixed: semantic <h2> styled visually via CSS utility class)
register_sidebar( array(
  'name'          => __( 'Blog Sidebar', 'mytheme' ),
  'id'            => 'sidebar-1',
  'before_title'  => '<h2 class="widget-title text-sm font-semibold">',
  'after_title'   => '</h2>',
) );
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("WordPress single post & sidebar follow sequential heading-order", async ({ page }) => {
  await page.goto("/blog/wcag-2-2-checklist/");
  const results = await new AxeBuilder({ page })
    .withRules(["heading-order"])
    .analyze();
  expect(results.violations).toEqual([]);
});

Template deduplication tip

A before_title => '<h4 class="widget-title">' declaration in functions.php triggers heading-order across every WordPress blog post and archive. Updating that one register_sidebar() call resolves every URL at once.

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

How do I change font size in a Gutenberg Heading block without picking H4?
Keep the block's semantic level as H2 or H3 in the toolbar, then open the Typography panel in the right sidebar and choose a smaller Font Size preset (S / M).
Should a WordPress post's 'Related Posts' or 'Leave a Reply' heading be an H2?
Yes—because those sections are top-level siblings of the main article body under the page <h1>, rendering them as <h2> (with individual related post cards as <h3>) guarantees zero skipped levels.
Can a WordPress site use multiple <h2> and <h3> headings on one page?
Absolutely. Going back up (for example <h3> -> <h2> for the next major section) is completely valid; heading-order only flags downward jumps that skip intermediate levels (like <h1> -> <h3> or <h2> -> <h4>).