KodingKaro
HTML · Beginner · Semantic HTML

Article, section, aside, and generic containers

Choosing the right grouping element makes it clearer whether content stands alone, belongs to a topic, or is secondary.

✓ What you will learn in this topic

  • Explain the purpose of Article, section, aside, and generic containers in a real HTML document.
  • Choose and apply the elements shown in both examples.
  • Recognize the specific mistake described in this lesson.

Concept explanation

Article is for a self-contained composition that could make sense on its own, such as a post or product review. Section groups a thematic part of a document and usually has a heading. Aside contains tangentially related information, such as a related-reading panel. Div remains useful when no semantic element fits and a grouping hook is needed, but div alone does not communicate a content role.

Syntax

Select article for standalone content, section for a headed theme, aside for related secondary content, and div only when no semantic role fits.

Example 1: a small page

The story is a complete item that could be shared or reused on its own.

<article>
  <h2>How I started birdwatching</h2>
  <p>A quiet morning walk became a weekly habit.</p>
</article>

Expected result: A standalone article displays with its own heading and paragraph.

Example 2: a practical page

The article is the main story; the aside points to relevant but secondary information.

<main>
  <article><h1>Choosing native plants</h1><p>Native plants support local insects.</p></article>
  <aside><h2>Related guide</h2><a href=\"/pollinators\">Meet pollinators</a></aside>
</main>

Expected result: The page separates its central article from a related guide panel.

Common mistakes

Do not choose semantic elements for their default appearance; their value comes from the meaning they convey.

Best practices

Use one main landmark for the page’s central content and select article, section, and aside according to the content relationship.

Practice exercise

Refactor a page of generic containers into header, nav, main, article or section, aside where relevant, and footer. Give each section a useful heading.

Lesson summary

  • Select content elements by relationship and use a generic div only when no semantic element fits.
  • Use one main landmark for the page’s central content and select article, section, and aside according to the content relationship.

Knowledge check

When is article a better choice than a generic div?

Show the explanation

Use article when the content forms a self-contained item that could stand on its own.

Practical example

html
<article>
  <h2>How I started birdwatching</h2>
  <p>A quiet morning walk became a weekly habit.</p>
</article>

Expected result:

A standalone article displays with its own heading and paragraph.

Hands-on practice task

Refactor a page of generic containers into header, nav, main, article or section, aside where relevant, and footer. Give each section a useful heading.

In this section

Other lessons in Semantic HTML

Broaden your knowledge

Related learning topics