Skip to content
Tutorials Center
My learning

Topics

HTML Reference ยท Sections

The <main> element

Reference for the HTML <main> element: marking the dominant content of a page, the one-main rule, the main landmark and skip links, examples and technical details.

The <main> element wraps the dominant content of the page: the part that is unique to this page and directly about its topic. Things that repeat across the site, like the header, main navigation, sidebars and the site footer, stay outside it.

HTML
<body>
  <header>โ€ฆ</header>
  <main>
    <h1>Order history</h1>
    โ€ฆ
  </main>
  <footer>โ€ฆ</footer>
</body>

Try it

A skip link that jumps to main

Attributes

This element has no attributes of its own. It accepts the global attributes.

Usage notes

  • Only one visible main. A document may have several <main> elements only if all but one are hidden with the hidden attribute, as single-page apps sometimes do when swapping views.
  • Keep it at the top level. <main> must not be inside an <article>, <aside>, <footer>, <header> or <nav>. Its ancestors can be <html>, <body>, <div>, a <form> without an accessible name, or a custom element.
  • The main landmark. It is exposed with the main role, and screen readers offer a shortcut to jump to it. That makes it the natural target for a "skip to main content" link, as in the example. See Keyboard Access and Focus.
  • Not a layout wrapper. If you need a centered container for the whole page, put a <div> around everything; <main> should contain only the main content.
  • Reader modes and some browser features use <main> to find the content worth keeping.

Technical summary

Content categories Flow content, palpable content
Permitted content Flow content
Tag omission None; both the start and end tags are required
Permitted parents Any element that accepts flow content, as long as <main> stays hierarchically correct (no <article>, <aside>, <footer>, <header> or <nav> ancestor)
Implicit ARIA role main
DOM interface HTMLElement
Default display block

Browser support

Supported in every current browser. Internet Explorer did not recognize it, which is why older code sometimes adds role="main"; that is no longer needed.