
- HTML - Home
- HTML - Roadmap
- HTML - Introduction
- HTML - History & Evolution
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - Document Object Model (DOM)
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <main> Tag
Introduction to <main> Tag
The HTML <main> tag is a semantic element that is used to identify the central content of a webpage that is unique and relevant to the primary purpose of the document. It is designed to include the main section of the webpage, excluding recurring elements like headers, footers and sidebars.
The <main> tag improves the accessibility and SEO as it allows screen readers and search engines to identify and to focus the important content. This tag is not nested within elements like <header>, <footer> or <article>.
Syntax
Following is the syntax of HTML <main> tag −
<main> ..... </main>
Attributes
HTML main tag supports Global and Event attributes of HTML.
Example : Basic Usage
Let's look at the following example, where we are going to consider the basic usage of the <main> tag.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML main Tag</title> </head> <body> <!--create a main element--> <p>Example of the HTML 'main' element(tag).</p> <main> <article> <h1>HTML</h1> <p>Hyper Text Markup Language</p> <p> The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. </p> <h1>CSS</h1> <p>Cascading Style Sheet</p> </article> </main> </body> </html>
Example : Excluding Nav and Footer
Consider the following example, where we are going to exclude the <nav> and <footer> tags.
<!DOCTYPE html> <html> <style> body{ color:green; font-family:verdana; } </style> <body> <nav> <ul> <li>HTML</li> <li>JAVA</li> <li>PYTHON</li> </ul> </nav> <main> <h2>Our Courses</h2> <p>Welcome to TutorialsPoint</p> </main> <footer> <p>Contact us: info@Tutorialspoint.com</p> </footer> </body> </html>
Example : Using <article> Element
In the following example, we are going to use the <article> element along with the <main> tag.
<!DOCTYPE html> <html> <style> body{ text-align:center; color:#8e44ad ; font-family:verdana; } </style> <main> <h1>TutorialsPoint</h1> <article> <h2>Courses</h2> <p>Search for the courses.</p> </article> <article> <h2>Coding Ground</h2> <p>Visit for different compilers.</p> </article> </main> </html>
Supported Browsers
Tag | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
main | Yes 26.0 | Yes 12.0 | Yes 21.0 | Yes 7.0 | Yes 16.0 |