Loading...
Loading...
00:00:00

<section> , <main> and <aside> tag in HTML5

The <section>, <main>, and <aside> tags in HTML5 are used to create HTML elements that provide structure and meaning to the content of a webpage. They are all semantic elements, which means that they give meaning to the content within the tags, rather than just providing a way to style the content.

section Tag

The <section> tag is used to create a section of a webpage that contains related content. Each <section> tag should have its own heading (<h1> - <h6>) that describes the content within the section. The <section> tag is a block-level element, which means that it creates a new block formatting context that takes up the entire width of its parent container. For example, if you want to create a section for a blog post, you could use the following code:

<section>
  <h2>My Blog Post</h2>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa.</p>
</section>

In this example, the <section> tag is used to create a section for the blog post, and the <h2> tag is used to provide a heading for the section.

main tag

The <main> tag is used to create the main content of a webpage. There should only be one <main> tag per webpage, and it should contain the content that is unique to the webpage and sets it apart from other pages on the website. The <main> tag is also a block-level element, and it creates a new block formatting context that takes up the entire width of its parent container. For example, if you want to create the main content for a webpage, you could use the following code:

<main>
  <section>
    <h2>About Us</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa.</p>
  </section>
  <section>
    <h2>Our Products</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa.</p>
  </section>
</main>

aside tag

The aside tag in HTML5 is used to define content that is tangentially related to the main content of a page. The aside tag can be used to mark up content such as sidebars, pull quotes, or advertisements. This tag is a semantic element, which means it provides information about the content it contains, rather than just specifying its appearance.

Here's an example of how the aside tag might be used in an HTML document:

<main>
  <h1>My Blog Post</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, 
  magna id commodo suscipit, est odio interdum lectus, at blandit turpis 
  libero vel libero. </p>
  <aside>
    <h2>Related Articles</h2>
    <ul>
      <li><a href="#">Article 1</a></li>
      <li><a href="#">Article 2</a></li>
      <li><a href="#">Article 3</a></li>
    </ul>
  </aside>
</main>

In this example, the main content of the page is contained within the main tag, and the related articles are contained within an aside tag. This makes it easy for a screen reader or other assistive technology to identify the different types of content on the page, and also makes it easier for developers to style the different elements using CSS.