Definition
The <main> tag is used to represent the main content of the <body> of a document. It contains the primary information on the page or main functionality of an app.
Example
<html>
<head>
<title>Document title</title>
</head>
<body>
<main>
<header>
<h1>Heading</h1>
</header>
<p>This is a paragraph</p>
</main>
<aside>
<h3>Navigation</h3>
<ul>
<li>Home</li>
<li>Another article</li>
</ul>
</aside>
</body>
</html>Usage
There must be only one
<main>element in a document, although<main>elements with ahiddenattributed are not included in this count.The
<main>element is not suitable for identifying the main content areas of subsectionsThe
<main>element must not be a descendant of an<article>,<aside>,<footer>,<header>or<nav>element.<header>elements can be included within the<main>tags if it is relevant to the page’s main content. Examples include in-page navigation links or article-specific<h1>headings.Both the opening and closing tags are required.
The content in the
<main>element should be unique to the document. Do not include content that appears across a set of documents, such as sidebars, navigation, logos, or content more suitable for the footer.The
<main>element is not sectioning content. It does not contribute to the page’s outline, unlike the<body>or heading tags.
Attributes
The main element only supports the Global Attributes.
Best Practices
- The
<main>element acts as the main landmark. It can help assistive technology, such as screen readers, identify and navigate the document’s main sections. - Browser reader mode functionality uses the
<main>element, along with headings, to identify the main content on the page when simplifying the user’s reading experience.
Specification
Browser Support
Desktop
| Chrome | Edge | Firefox | IE | Opera | Safari |
|---|---|---|---|---|---|
| Yes | Yes | Yes | No^ | Yes | Yes |
^ To support IE 11 and lower you can add role="main" to the <main> element.
Mobile
| Android Webview | Chrome Android | Firefox Android | Opera Android | iOS Safari | Samsung Internet |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
