Main landmark should not be contained in another landmark

How to fix the landmark-main-is-top-level accessibility rule. Headings and landmarks. A best practice, not a WCAG requirement.

The message you saw

axe-core, axe DevTools and this checker
Main landmark should not be contained in another landmark (rule landmark-main-is-top-level)

Lighthouse has no audit for this rule, so you’ll only see it from axe-core based tools.

What it means

The <main> element (or role="main") is inside another landmark, such as a <header> that is the site banner, a <nav>, an <aside>, a <footer>, a named <section> or a role="region". The main landmark should be one of the page’s top-level areas, side by side with the header and footer.

This often happens when a whole page is wrapped in a <div role="region"> or <section aria-label> by a framework or page builder.

Who is affected

The main landmark is nested inside another landmark, which makes the page outline confusing for screen-reader users.

Screen readers show landmarks as a tree. A main landmark nested inside, say, a navigation landmark is confusing: users jumping to “navigation” get the content, and the page outline doesn’t match what they see.

This is a best practice, not a WCAG requirement.

How to find it

  1. Run the checker: it outlines the <main> that’s nested.
  2. In DevTools, select the <main> and look at its ancestors in the breadcrumb at the bottom of the Elements panel for header, nav, aside, footer, a named section or a role attribute.

How to fix it

  1. Move <main> out so its parent is <body> (or a plain <div> wrapper).
  2. If a wrapper around the whole page has a landmark role or a name that makes it a region, remove that role or name.

Example

Before

<section aria-label="Page">
  <header>…</header>
  <main>…</main>
</section>

After

<div class="page">
  <header>…</header>
  <main>…</main>
</div>

WCAG success criteria

None. This is a best practice: fixing it helps people using assistive technology, but it doesn’t affect WCAG conformance. Our scanner only reports it if you tick “Also show best-practice suggestions”.

Check your fix

Scan a web page and the report lists every element that fails this rule, with screenshots outlining where they are, the code, and a selector you can paste into your browser’s developer tools. Scan again after your change: when the rule no longer appears under the problems, the fix worked.

An automated pass means this rule found nothing wrong. It doesn’t prove the page is accessible: some of what WCAG asks for needs a person to check, and the report’s manual checklist lists those steps.

Related fix guides

More detail