The
<main>tag represents the dominant content of the<body>of a webpage.
It should contain content unique to the page, excluding repeated elements like headers, footers, sidebars, or navigation links.<main>helps assistive technologies and search engines quickly identify the primary content of the page.
Syntax
<main>
<!-- Primary page content -->
</main>Attributes
| Attribute | Description |
|---|---|
| id | Assigns a unique identifier. |
| class | Specifies one or more class names. |
| style | Inline CSS styling. |
| title | Provides additional information about the element. |
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Main Tag Example</title>
</head>
<body>
<header>
<h1>Website Header</h1>
</header>
<main style="padding: 20px; background-color: #f9f9f9;">
<h2>Welcome to Our Website</h2>
<p>This is the primary content of the page, containing unique information for visitors.</p>
<p>Content in <main> should not include repeated site elements like navigation or footer links.</p>
</main>
<footer>
<p>© 2025 My Website</p>
</footer>
</body>
</html>Output
Browser Output
You will see a distinct main content area with headings and paragraphs.
Content inside <main> is considered the primary page content and is separate from headers, footers, and sidebars.
Use our TryIt Editor to experiment with <main> styling and structure.
Browser Support
Chrome | Firefox | Edge | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| ✅Yes | ✅Yes | ✅Yes | ✅Yes | ✅Yes | ❌No |
All major browsers support <main> tag.
Notes
<main>should only appear once per page.- Excludes repeated content like
<header>,<footer>, and<aside>. - Improves accessibility, allowing screen readers to jump directly to main content.
- Helps SEO by signaling primary content to search engines.
Conclusion
The <main> tag is essential for defining the main content of a webpage.
It provides semantic meaning, accessibility benefits, and clarity for both users and search engines.