Table of Contents
INTRODUCTION
The HTML <main> element represents the dominant content of the <body> of a document. The main content area includes information that is directly relevant to or builds upon the core subject of a document or the primary function of an application.
The content within <main> element should be unique to the document. Elements that are commonly repeated across multiple documents or sections, such as sidebars, navigation menus, copyright details, site logos, and search forms, should be excluded.
Example:
<header>
<h1>Website Header</h1>
</header>
<main>
<h2>Welcome to My Website</h2>
<p>This is the main content area of the webpage.</p>
</main>
Usage Guidelines
- Role - The <main> element functions as a main landmark role, allowing assistive technology to quickly recognize and navigate to key sections of a document.
- Can Not Include - The <main> element cannot be a descendant of <article>, <aside>, <footer>, <header>, or <nav>.
- Unique - You should only have one <main> element per page. Multiple <main> elements can confuse browsers and assistive technologies.
- Skip navigation, or "skipnav," is a method that enables assistive technology users to swiftly bypass repetitive content, such as main navigation menus and informational banners. This helps them reach the main content of a webpage more quickly.
- The browser's reader mode functionality detects the <main> element, when it transforms content into a streamlined reader view.
Attributes
The <main> element only includes global attribute.
Tag Omission
The HTML <main> element must have both start tag and end tag.