HTML <main>
Tag Tutorial
In HTML, the <main>
tag is used to define the main content of a webpage. It should contain the central content that is unique to the specific webpage, such as articles, blog posts, or forum discussions.
Here is an example of how to use the <main>
tag:
<main>
<article>
<h2>Welcome to our Blog!</h2>
<p>Check out our latest posts.</p>
</article>
</main>
The content inside the <main>
tag should not include navigation links, advertisements, site logos, or other content that is repeated on multiple pages.
Now, let's take a look at the attributes of the <main>
tag:
Attribute | Description |
---|---|
id | Specifies a unique id for the <main> tag |
class | Specifies a class for the <main> tag |
Here is an example of how to use the id
attribute with the <main>
tag:
<main id="main-content">
<section>
<h2>About Us</h2>
<p>Learn more about our company.</p>
</section>
</main>
And here is an example of using the class
attribute:
<main class="main-content">
<section>
<h2>Contact Us</h2>
<p>Get in touch with us today.</p>
</section>
</main>