Sign Up

Sign In

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Sorry, you do not have permission to ask a question, You must login to ask a question.

SIKSHAPATH Latest Articles

What is the Difference Between Section, Article and Aside in HTML5?

A man coding in html5, the banner texted with section, article and aside HTML.

HTML5 introduced several new semantic elements that help developers and browsers understand the structure and meaning of a web page. Among these elements are section, article and aside, which are often used to organize the content of a document.

But what is the difference between them and how should you use them correctly?

In this article, we will explain the purpose and usage of each element and provide some examples to illustrate their differences.

Difference Between Section, Article and Aside in HTML5

Section

The section element defines a logical group of related content, such as a chapter, a header, a footer or any other section of the document. It is not tied to any position in a document and can be used anywhere that makes sense. The section element is a generic container that can hold any kind of flow content, such as paragraphs, lists, images, tables, etc.

However, it should not be used as a replacement for the div element, which is meant for styling purposes only. The section element should have a heading that describes its content and can also have an id attribute to identify it.

For example, you can use the section element to divide your document into different parts, such as introduction, main content and conclusion. You can also use it to group related articles or news items together.

Here is an example of how to use the section element:

<html>
<section id="introduction">
  <h1>What is HTML5?</h1>
  <p>HTML5 is the latest version of the HyperText Markup Language...</p>
</section>
<section id="main-content">
  <h2>Features of HTML5</h2>
  <p>HTML5 introduces many new features and improvements...</p>
  <!-- more content -->
</section>
<section id="conclusion">
  <h3>Why use HTML5?</h3>
  <p>HTML5 offers many benefits for web developers and users...</p>
</section>
</html>

Article

The article element specifies independent, self-contained content that can stand on its own and be distributed separately from the rest of the site. Examples of such content are blog posts, news stories, comments or forum posts.

The article element can also be nested inside another article element to represent related content. The article element can contain any kind of flow content, but it should have a heading that identifies its topic and can also have an author, date and other metadata.

For example, you can use the article element to mark up each post on your blog or each news item on your site. You can also use it to mark up each comment or reply on your forum.

Here is an example of how to use the article element:

<html>
<article>
  <header>
    <h1>What is the difference between section and article and aside in HTML5?</h1>
    <p>Posted by John Doe on May 10th, 2023</p>
  </header>
  <section class="main">
    <p>In this article, we will explain the purpose and usage of each element...</p>
    <!-- more content -->
  </section>
  <footer>
    <p>Comments:</p>
    <article>
      <header>
        <p>Posted by Sikshapath on May 10th, 2023</p>
      </header>
      <p>Great article! Thanks for sharing.</p>
    </article>
    <!-- more comments -->
  </footer>
</article>
</html>

Aside

The aside element represents content that is related to the main content but not essential to it, such as a brief commentary, an analogy, a sidebar or related links. It is often presented as a side note or a call-out box that provides additional information or context.

The aside element can contain any kind of flow content, but it should not be used for parenthetical text that is part of the main flow. The aside element can be placed inside or outside an article or section element depending on its relevance.

For example, you can use the aside element to provide some background information or explanation about a topic in your article or section. You can also use it to display some related content or links that might interest your readers.

Here is an example of how to use the aside element:

<html>
<article>
  <header>
    <h1>What is HTML5?</h1>
    <p>HTML5 is the latest version of the HyperText Markup Language...</p>
  </header>
  <section class="main">
    <p>HTML5 introduces many new features and improvements...</p>
    <!-- more content -->
    <aside>
      <h2>Did you know?</h2>
<p>HTML5 was first published as a draft in 2008 and became a standard in 2014.</p>
    </aside>
  </section>
  <footer>
    <p>Posted by John Doe on May 10th, 2023</p>
  </footer>
</article>
</html>

Wrap up

In this article, we have explained the difference between section, article and aside elements in HTML5 and how they can help you structure your web pages semantically. We have also provided some examples of how to use these elements correctly and effectively.

By using these semantic elements, you can make your web pages more meaningful and accessible for both the browsers and the users. You can also improve your SEO and web performance by using these elements appropriately.

We hope you have learned something new and useful from this article. If you have any questions or comments, please feel free to leave them below. Thank you for reading!

Also Read

Websites to Practice Programming

Related Posts

Leave a comment

You must login to add a new comment.

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock