main – main content
<main>…</main>
The main content of the page – what the visitor came for. Parts repeated on every page of the website do not belong in it: the header with the logo, the main menu, a sidebar with links and the footer.
- Default display:
display: block - End tag: required
- Content: flow content
- Where it can be used: where flow content is allowed, but not inside
article,aside,header,footerornav - DOM interface:
HTMLElement
Attributes
Only global attributes.
Examples
A page skeleton with a link that skips the menu – keyboard users jump straight to the content with it:
<body>
<a class="skip-link" href="#content">Skip to content</a>
<header>…</header>
<nav aria-label="Main menu">…</nav>
<main id="content">
<h1>Sourdough bread</h1>
<p>Baked every morning.</p>
</main>
<footer>…</footer>
</body>
Accessibility
main has the main role. Screen readers can jump to it with a single key and so skip the header and the menu. A “Skip to content” link at the start of the page does the same for keyboard users without a screen reader – it may be hidden, but it must appear when it receives focus.
Things to watch out for
- A page may have only one visible
main. Others (for example individual “screens” of an application) must have thehiddenattribute. - It must not be inside
article,aside,header,footerornav. - Old Internet Explorer did not treat
mainas a block – hence the unnecessarymain { display: block; }in some stylesheets.
Browser support
Baseline – widely available: works in all major browsers and has for a long time (since 2015 at the latest). Since version: Chrome 26, Firefox 21, Safari 7. As of October 2026 (MDN browser-compat-data).
Related:
header – header
nav – navigation
footer – footer
article – self-contained content
aside – complementary content
hidden – hidden element (attribute)