<main> Tag in HTML

Quick facts

CategoryFlow content, palpable content
Content modelFlow content
Tag omissionNeither the start nor end tag can be omitted
Permitted parentsAny element that accepts flow content, but must not be a descendant of <article>, <aside>, <footer>, <header>, or <nav>
DOM interfaceHTMLElement

Syntax

<main> ... </main>

Live example

Edit the code below and watch the preview update instantly.

index.html
Preview

Attributes

AttributeDescription
—<main> has no attributes of its own — only the global attributes shared by every HTML element.

Common examples

The standard page skeleton

Header and footer repeat across the site; <main> holds what is unique to this page.

<body> <header>…logo and menu…</header> <main> <h1>Page title</h1> <p>The content of this page.</p> </main> <footer>…</footer> </body>

A target for a “Skip to content” link

Give main an id so keyboard users can jump straight past the menu.

<a href="#main" class="skip-link">Skip to content</a> <header>…</header> <main id="main">…</main>

A centered, readable content column

Limit the width of main and center it, so text never stretches across a wide screen.

<main class="content">…</main> <style> .content { max-width: 70ch; margin: 0 auto; padding: 2rem 1rem; } </style>

Main with a sidebar

A sidebar of related links sits next to main, not inside it, as an <aside>.

<div class="layout"> <main>…article…</main> <aside>…related links…</aside> </div> <style> .layout { display: grid; grid-template-columns: 3fr 1fr; gap: 2rem; } </style>

<main> vs <body>

The <body> holds everything visible on the page: the header, navigation, sidebars, footer and the content itself. <main> holds only the part that is unique to this page — the article, the product, the search results — leaving out everything that repeats from page to page.

So a page has one body and, inside it, one visible main. Marking that main area helps screen reader users skip straight to the content and helps search engines tell the real content apart from the site-wide template.

<main><body>
ContainsUnique page contentEverything visible
How manyOne visible per pageExactly one
Includes header/footerNoYes

Common mistakes to avoid

  • More than one visible main. A page should have a single main area; additional ones must be hidden with the hidden attribute.
  • Putting the site header, menu or footer inside main. They repeat on every page, so they belong outside it.
  • Nesting main inside an article, aside, header, footer or nav. That isn’t allowed; main sits at the top level of the page structure.
  • Leaving it out entirely. Without main, screen reader users have no quick way to skip to the content.

Accessibility & SEO tips

  • Main is a landmark: screen readers can jump straight to it, and a “Skip to content” link pointing at it helps keyboard users too.
  • Put the page’s <h1> at the start of main (or in the page header just above it), so the content starts with a clear title.
  • Search engines use the page structure to separate content from boilerplate, so keeping the real content inside main makes your page easier to understand.
  • Don’t hide main content in tabs or accordions that only open with JavaScript — visitors and search engines should be able to reach the important text directly.

Browser support

Supported in all modern browsers, including Chrome, Edge, Firefox, Safari and their mobile versions. It was introduced with HTML5, and only very old browsers such as Internet Explorer 8 needed workarounds.

Related tags

Frequently asked questions

Can I have more than one <main> on a page?
No — there should be exactly one visible <main> element per page.
Why does <main> matter for accessibility?
Screen readers offer a "skip to main content" shortcut that relies on this element, letting users bypass repeated navigation on every page.
Should the page <h1> be inside <main>?
Usually yes: starting main with the <h1> means the content begins with its title. Putting the <h1> in the page <header> just above main is also fine.
Does <main> help SEO?
Indirectly. It helps search engines identify the primary content of the page and separate it from navigation, sidebars and footers.
Do I need <main> on every page?
It's best practice. Every page has some primary content, and wrapping it in <main> gives screen reader users a consistent way to reach it.
Can <main> be inside a <div>?
Yes. Wrapping main in a div for layout, for example a grid with a sidebar, is fine. What isn't allowed is placing it inside article, aside, header, footer or nav.
What is the difference between <main> and <article>?
Main marks all the unique content of the page and appears once. An article is one self-contained piece, so a blog index page has one main containing many articles.