Heading order, landmarks, and axe-core's best-practice rules
Some of the most familiar axe-core findings are not WCAG failures at all. They are best practice: good advice, worth following, and a different thing from a success criterion. Knowing which is which decides what should break a build.
Two kinds of rule
Every axe-core rule carries tags. Most are tagged with a WCAG level and one or more success
criteria: color-contrast with 1.4.3, label with 4.1.2. A failure of one of those rules is
evidence of a failure of that criterion.
A second group is tagged best-practice instead. These encode advice that experienced
practitioners agree on, and that makes pages easier to use with assistive technology, but
that WCAG does not require. Among them:
heading-order(opens in a new tab): heading levels should only increase by one.page-has-heading-one: a page should have a level-one heading.empty-heading: headings should have text.region(opens in a new tab): all content should be inside a landmark.landmark-one-main(opens in a new tab): a page should have onemainlandmark.landmark-unique: landmarks of the same type should be distinguishable by name.
A page that fails heading-order has not, on that evidence alone, failed WCAG.
1.3.1 Info and Relationships (opens in a new tab)
asks that headings be marked up as headings; it does not require levels to run in sequence.
2.4.1 Bypass Blocks (opens in a new tab) asks for
a way to skip repeated content, and landmarks are one way to provide it, not the only one.
How the standard option decides
Skiplink's standard option selects rules by those tags. The default, wcag22aa, runs the
rules for WCAG 2.0, 2.1 and 2.2 at levels A and AA, and so leaves best-practice rules out.
all runs everything axe-core ships, best practice included. The
standards table lists every value.
It is the same option everywhere:
# CLI
npx @skiplink/cli scan https://staging.example.com --standard all
# GitHub Action
- uses: skiplink/action@v1
with:
urls: https://staging.example.com
standard: all
token: ${{ secrets.SKIPLINK_TOKEN }}
The API takes "standard": "all" in the scan request, and the
Playwright adapter takes standard as an option.
Headings: before and after
The usual cause of a heading-order finding is picking a heading level for its size:
<!-- Before: h3 straight after h1, because h3 was the right size -->
<h1>Pricing</h1>
<h3>Monthly plans</h3>
<h3>Annual plans</h3>
<!-- After: levels describe structure; CSS describes size -->
<h1>Pricing</h1>
<h2 class="heading-small">Monthly plans</h2>
<h2 class="heading-small">Annual plans</h2>
Screen reader users commonly move through a page by headings, and a list of headings is
often how they first learn its shape. A jump from 1 to 3 suggests a missing section.
It is a minor inconvenience compared with headings that are not headings at all, such as a
bold <div> styled to look like one, which is the 1.3.1 problem.
Landmarks: before and after
Landmarks let a screen reader user jump straight to the navigation or the main content. HTML elements give you them without any ARIA:
<!-- Before: everything is a div; region and landmark-one-main both fire -->
<body>
<div class="top">…</div>
<div class="menu">…</div>
<div class="content">…</div>
<div class="bottom">…</div>
</body>
<!-- After -->
<body>
<header>…</header>
<nav aria-label="Main">…</nav>
<main>…</main>
<footer>…</footer>
</body>
<header> and <footer> become the banner and contentinfo landmarks only when they are not
inside an <article>, <section>, <main> or similar, so a footer inside a blog post card
is not a second page footer. If you have two <nav> elements, give each a distinct
aria-label. The W3C's landmark regions pattern (opens in a new tab)
covers the rest.
The usual region findings after that are things injected outside your layout: cookie
banners, chat launchers, toast containers appended to <body>. Put them inside a landmark
where you control the markup, or give the container a role and label.
Should best practice break the build?
The docs put it plainly: failing a build on best-practice rules is a choice, not a requirement. Reasonable teams choose differently. Two approaches work:
Gate on WCAG, report on the rest. Keep the blocking check on wcag22aa, and add a second
step that runs all without failing:
- uses: skiplink/action@v1
continue-on-error: true
with:
urls: https://staging.example.com
standard: all
fail-on: never
comment: false
token: ${{ secrets.SKIPLINK_TOKEN }}
The report lands in the job summary, and nothing goes red. comment: false keeps the
pull request to one comment, from the blocking step.
Gate on everything. If your site is new or your debt is small, all with a baseline is a
stricter gate that also keeps structure from drifting. If you switch an existing gate from
wcag22aa to all, re-record the baseline in the same pull request; otherwise every
best-practice finding counts as new on the first run.
What no rule can tell you
The rules check structure, not meaning. A page whose headings run 1, 2, 2, 3 in perfect order
and say "Overview", "Details", "More" passes everything here. Whether headings and labels
describe their content is
2.4.6 Headings and Labels (opens in a new tab),
and the criteria table shows it has no automated rule at all. Nor can a rule
tell whether a <main> wraps the main content or a sidebar. Reading the headings list and
the landmarks list in a screen reader takes a minute per template and answers both.
What a scan does not tell you covers the wider limits.
Related
- The WCAG 2.2 additions, and which of them a scanner can detect
- API Reference & CI Gate Documentation
- What automated testing can and cannot detect — WCAG 2.2 reference
Try it on your own site: scan a URL for free, or read the docs to add a baseline to your pipeline.