Contains all visible content including main. Learn more →
<main> ElementThe <main> element represents the dominant content of the document’s body. It contains the central topic or main functionality of the page, excluding content that is repeated across multiple pages like navigation, headers, footers, and sidebars.
<main> <!-- Primary page content --></main>The <main> element has no element-specific attributes.
This element supports all global attributes.
The main content of a blog post, excluding navigation and footer:
The product details are the main content, while navigation and promotional banners are outside:
Search results are the main content:
The dashboard content is main, while the app navigation is outside:
Only one <main> element should be visible at a time:
<!-- Correct: Single main element --><body> <header>...</header> <main> <h1>Page Content</h1> </main> <footer>...</footer></body>
<!-- Also correct: Multiple main elements with hidden --><body> <main id="primary-content"> <h1>Default Content</h1> </main> <main id="alternative-content" hidden> <h1>Alternative View</h1> </main></body>Provide a skip link for keyboard users:
The <main> element should not be nested inside <article>, <aside>, <footer>, <header>, or <nav>:
<!-- Wrong: main inside article --><article> <main> <h1>Content</h1> </main></article>
<!-- Correct: main contains article --><main> <article> <h1>Content</h1> </article></main>Combine <main> with other semantic elements for best structure:
<body> <header> <h1>Site Name</h1> <nav><!-- Site navigation --></nav> </header>
<main> <article> <header> <h2>Article Title</h2> </header> <section> <h3>Section 1</h3> <p>Content...</p> </section> </article>
<aside> <!-- Related content that's part of the main content --> </aside> </main>
<footer> <!-- Site footer --> </footer></body>The <main> element has an implicit ARIA role of main, creating a landmark that assistive technologies can navigate to:
<!-- These are equivalent --><main>Content</main><div role="main">Content</div>Screen reader users can jump directly to the main content using landmark navigation:
If you have multiple <main> elements (with hidden), label them:
<main id="primary" aria-label="Primary content"> <h1>Default View</h1></main>
<main id="alternative" aria-label="Alternative content" hidden> <h1>Alternative View</h1></main>| Browser | Version |
|---|---|
| Chrome | 26+ |
| Firefox | 21+ |
| Safari | 7+ |
| Edge | All versions |
| IE | 11+ (with polyfill for IE 9-10) |
Contains all visible content including main. Learn more →
Self-contained content, often used within main. Learn more →
Thematic grouping of content within main. Learn more →
Tangentially related content, can be inside or outside main. Learn more →
<!-- Wrong: Multiple visible main elements --><body> <main> <h1>Content 1</h1> </main> <main> <h1>Content 2</h1> </main></body>
<!-- Correct: Hide all but one --><body> <main> <h1>Visible Content</h1> </main> <main hidden> <h1>Hidden Alternative</h1> </main></body><!-- Wrong: Navigation in main --><main> <nav> <a href="/">Home</a> <a href="/about">About</a> </nav></main>
<!-- Correct: Navigation outside main --><nav> <a href="/">Home</a> <a href="/about">About</a></nav><main> <h1>Page Content</h1></main>