KodingKaro
HTML · Intermediate · Semantic Page Layouts

Choose semantic elements by content purpose

Real pages combine multiple kinds of content. Good semantic choices make those relationships easier to maintain and navigate.

✓ What you will learn in this topic

  • Explain the purpose of Choose semantic elements by content purpose in a real HTML document.
  • Choose and apply the elements shown in both examples.
  • Recognize the specific mistake described in this lesson.

Concept explanation

A page should be modeled around what each region does, not around the boxes in a visual mockup. Use nav for a major group of destinations, main for the unique central task, article for a self-contained item, and section for a themed part of a larger item. A card is not automatically an article: ask whether its content makes sense independently. Use div when you need a neutral hook and no semantic element describes it.

Syntax

Build the document outline from meaningful regions, then use neutral containers only for purely presentational grouping.

Example 1: a small page

Main contains the central page content; the section has a clear subject and heading.

<main>
  <h1>Course: Garden Basics</h1>
  <section><h2>What you will learn</h2><p>Plan a small growing space.</p></section>
</main>

Expected result: The page has one main heading and a titled section describing the course.

Example 2: a practical page

The course description stands on its own; the related preparation note is secondary.

<main>
  <article><h1>Urban gardening course</h1><p>A practical course for balcony growers.</p></article>
  <aside><h2>Before you begin</h2><a href=\"/tools\">Check your light</a></aside>
</main>

Expected result: The course page exposes its main offer separately from its related preparation guide.

Common mistakes

Do not use section as a generic styling wrapper. A section should represent a theme and normally have a heading.

Best practices

Sketch the page outline first, identify its repeated and unique regions, then select semantic elements for the content relationships.

Practice exercise

Outline a course detail page with site navigation, a course introduction, lesson articles, related resources, and contact information. Select semantic elements and explain why each fits.

Lesson summary

  • Select semantic elements by content role and relationship rather than by appearance.
  • Sketch the page outline first, identify its repeated and unique regions, then select semantic elements for the content relationships.

Knowledge check

What question helps determine whether content belongs in an article?

Show the explanation

Ask whether it forms a self-contained item that could be understood or reused on its own.

Practical example

html
<main>
  <h1>Course: Garden Basics</h1>
  <section><h2>What you will learn</h2><p>Plan a small growing space.</p></section>
</main>

Expected result:

The page has one main heading and a titled section describing the course.

Hands-on practice task

Outline a course detail page with site navigation, a course introduction, lesson articles, related resources, and contact information. Select semantic elements and explain why each fits.

In this section

Other lessons in Semantic Page Layouts

Broaden your knowledge

Related learning topics