The axe accessibility rule All page content must be contained by landmarks states that all top html elements should be landmark elements, eg
<html lang="en">
<head>
<title>Hello</title>
</head>
<body>
<header>This is the header</header>
<nav>This is the nav</nav>
<main>This is the main</main>
<footer>This is the footer</footer>
</body>
</html>
But a React project requires a root element below body (required to avoid collisions with other scripts
<html lang="en">
<head>
<title>Hello</title>
</head>
<body>
<div id="root">
<header>This is the header</header>
<nav>This is the nav</nav>
<main>This is the main</main>
<footer>This is the footer</footer>
</div>
</body>
</html>
I tried to set aria-hidden="true"
to my div for screen-readers to ignore it
<div id="root" aria-hidden="true">
But this raises another issue: aria-hidden elements do not contain focusable elements
I couldn't find other people discussing this issue, which makes me wonder if it's relevant at all. Is there a clean way to have a react app with landmark top elements? Or should I just ignore this specific axe rule?