Kodokon kodokon.com

Semantic HTML: structuring a real page

Replace your anonymous divs with tags that give meaning to your structure.

8 min · 3 questions

Open this lesson in Kodokon

A page built entirely out of div elements works, but it says nothing: not to screen readers, not to search engines, and not to the colleague who will pick up your code in six months. Semantic tags describe the role of each area: header, nav, main, article, section, footer.

HTML
<body>
  <header>
    <nav aria-label="Main navigation">
      <a href="/">Home</a>
      <a href="/articles">Articles</a>
      <a href="/contact">Contact</a>
    </nav>
  </header>

  <main>
    <h1>The blog for curious devs</h1>
  </main>

  <footer>
    <p>&copy; 2026 Kodokon. All rights reserved.</p>
  </footer>
</body>
The standard semantic skeleton of a page.

header groups the page header (logo, navigation), footer the closing information (legal notices, secondary links). main holds the main content and must be unique on the page. nav marks a navigation area: the main navigation, a breadcrumb trail or a table of contents.

The trickiest distinction: article versus section. Rule of thumb: if the block makes sense out of context (a blog post, a comment, a product card), it's an article. If it's a thematic grouping inside a piece of content, with its own heading, it's a section.

HTML
<main>
  <article>
    <h1>Understanding semantic HTML</h1>
    <section>
      <h2>Accessibility</h2>
      <p>Screen readers rely on the
      structure to navigate.</p>
    </section>
    <section>
      <h2>SEO</h2>
      <p>Search engines understand the page better.</p>
    </section>
  </article>
</main>
A standalone article split into titled sections.

Mental exercise: on an e-commerce product page, how would you mark up the list of customer reviews? Each review has an author, a date and content that stands on its own: each review is therefore an article, and the "Customer reviews" block that groups them, with its heading, is a section.

Knowledge check

Make sure you remember the key points of this lesson.

  1. How many main elements should a page contain?
    • Just one, holding the main content
    • One per section of the page
    • Two at most: one for desktop, one for mobile
  2. Which element should you pick for a blog comment that makes sense out of context?
    • section
    • div
    • article
    • aside
  3. What is the main benefit of semantic HTML over divs everywhere?
    • The page loads faster
    • Machines (screen readers, search engines) understand the structure
    • Semantic tags apply automatic styling