Fix landmark-one-main in React
Single-page React applications mounted inside <div id='root'> frequently wrap the entire router outlet in nested <div> containers with zero semantic landmarks. Switching the primary router viewport in <AppShell> to <main id='main-content' tabIndex={-1}> gives screen-reader users immediate landmark navigation across every view.
Before and after
// src/components/AppShell.tsx (Broken React SPA shell with only <div> containers)
import { Outlet } from "react-router-dom";
export function AppShell() {
return (
<div className="app-shell">
<div className="top-bar">Top Navigation</div>
<div className="content-area">
<Outlet />
</div>
</div>
);
}// src/components/AppShell.tsx (Fixed semantic landmarks: <header>, <main>, <footer>)
import { Outlet } from "react-router-dom";
export function AppShell() {
return (
<div className="app-shell">
<a href="#main-content" className="skip-link">
Skip to main content
</a>
<header className="top-bar">
<nav aria-label="Primary">Top Navigation</nav>
</header>
<main id="main-content" tabIndex={-1} className="content-area">
<Outlet />
</main>
<footer className="site-footer">© 2026 Acme Inc.</footer>
</div>
);
}Fixed vs. broken example
Pair your single <main id="main-content" tabindex="-1"> landmark with a visible-on-focus "Skip to main content" link at the top of <body>.
Playwright + axe-core check
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test("React SPA layout exposes one <main> landmark across routes", async ({ page }) => {
await page.goto("/projects");
await expect(page.getByRole("main")).toHaveCount(1);
const results = await new AxeBuilder({ page })
.withRules(["landmark-one-main"])
.analyze();
expect(results.violations).toEqual([]);
});Template deduplication tip
Fixing your top-level <AppLayout /> shell once resolves landmark-one-main across every client-side route in your React application.
What NVDA and VoiceOver announce
Keyboard and screen-reader users rely on the <main> landmark (and Skip-to-Content links targeting it) to bypass 30+ repeating header, mega-menu, and announcement links on every page navigation.
NVDA (Windows)
Pressing D (next landmark) announces: "no next landmark"
Pressing D jumps straight past navigation and announces: "main landmark"
VoiceOver (macOS / iOS)
Landmarks rotor shows no Main region; user must step through every header link.
Landmarks rotor lists "main", letting the user jump directly to primary content.
Common questions
Why should a React SPA keep <main> outside <Routes> / <Outlet>?
Should React move focus to <main> on client-side route transitions?
Can a React modal portal render a second <main>?
Test a URL for landmark-one-main
Enter any public URL for a free WCAG 2.2 AA check—no account or credit card required.
Shipping React weekly? Block new landmark-one-main regressions in PRs with our baseline-diff GitHub Action PR gate (≤20 URLs/PR).