Skip to content

a11y: Add main and region landmarks - #1996

Merged
marcleblanc2 merged 1 commit into
mainfrom
marc/a11y/landmarks
Sep 17, 2026
Merged

marcleblanc2 merged 1 commit into
mainfrom
marc/a11y/landmarks

Conversation

@marcleblanc2

Copy link
Copy Markdown
Contributor

Problem

axe-core flags every page with landmark-one-main (1 node) and region (19 nodes on the home page, 66 on a docs page), both impact: moderate. There is no <main>, so all page content sits outside any landmark and screen reader users cannot jump straight to it.

Fix

  • The page-content container <div> becomes <main> on the home page (page.tsx), docs pages ([...slug]/page.tsx) and the 404 page (not-found.tsx). It keeps its classes, so it stays a flex sibling of the sidebar and TOC and the layout does not change.
  • The home page Hero becomes a <section aria-labelledby="hero-title">, so its heading and intro text are inside a named region.

I chose this over wrapping {children} in Layout.tsx because children is a fragment of flex siblings (content + TOC); wrapping it would have broken the three-column layout, and would have put the sidebar <nav> inside <main>.

Verification

axe-core 4.12 via Playwright against a local next dev, on /, /admin/audit-log and a 404 URL, light and dark: landmark-one-main and region go to 0 on all six runs.

Home page screenshot before and after is byte-identical (cmp on two 1440×900 PNGs).

Part of a set of three a11y PRs; the other two fix button-name and color-contrast.

@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sourcegraph-docs Ready Ready Preview Sep 17, 2026 9:58am UTC

Request Review

@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@marcleblanc2
marcleblanc2 marked this pull request as ready for review September 17, 2026 09:11
@marcleblanc2
marcleblanc2 requested review from a team and enriquegh September 17, 2026 09:11
@marcleblanc2
marcleblanc2 enabled auto-merge (squash) September 17, 2026 09:56
axe-core flags every page with landmark-one-main and region
violations (moderate): there is no <main>, so page content sits
outside any landmark and screen reader users cannot jump to it.

Make the page content container a <main> on the home, docs and 404
pages, and make the home page hero a <section> labelled by its
heading. Both keep their classes, so the layout does not change.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0ae7e-ae2c-7423-be36-eb9c5884b1e0
Co-authored-by: Amp <amp@ampcode.com>
@marcleblanc2
marcleblanc2 merged commit e677bc6 into main Sep 17, 2026
6 checks passed
@marcleblanc2
marcleblanc2 deleted the marc/a11y/landmarks branch September 17, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants