Skip to content
Kuza Ndoto Academy

Semantic HTML

BeginnerChapter 3 · Page 14 of 254 min readUpdated 15 Nov 2026

Semantic HTML means choosing elements for what content is, not how it looks. Modern HTML has elements for the main regions of a page: <header>, <nav>, <main>, <article>, <section>, <aside> and <footer>. Using them makes your pages easier to navigate with assistive technology, easier for search engines to understand and easier for other developers to read.

Div soup versus semantic markup

Here are two versions of the same page layout:

<!-- Div soup: tells the browser nothing -->
<div class="top">…</div>
<div class="menu">…</div>
<div class="content">…</div>
<div class="bottom">…</div>

<!-- Semantic: every region has a meaning -->
<header>…</header>
<nav>…</nav>
<main>…</main>
<footer>…</footer>

Both look identical without CSS. The difference is invisible but powerful: in the semantic version, a screen-reader user can jump straight to the navigation or the main content, because these elements create landmarks.

The page-level elements

<header> logo and site name <nav> main menu links <main> the page's unique content <article> a blog post <section> with its own h2 <section> with its own h2 <aside> related links, extra information <footer> copyright and contact
Figure 1. A common layout. The elements describe roles, not positions: CSS decides where each box actually appears on screen.
ElementMeaning
<header>Introductory content: logo, site name, maybe a search box. A page can also have headers inside articles.
<nav>A block of major navigation links, such as the main menu or a table of contents.
<main>The main content, unique to this page. Use only one visible <main>, and don't put it inside <header>, <nav>, <article>, <aside> or <footer>.
<article>A self-contained piece that would make sense on its own: a blog post, news story, product card or comment.
<section>A thematic group of content, normally with its own heading.
<aside>Content related to the surrounding content but not part of its main flow: a sidebar, related links, a glossary box.
<footer>Closing information: copyright, contact details, related links. Articles can have their own footers too.

article or section?

This is the question beginners ask most. A simple test: could the content be published somewhere else on its own and still make sense? If yes, it's an <article>. A news story could appear in a newsfeed or an app, so it is an article. "Our Services" and "Testimonials" on a business home page are parts of that page, so they are sections.

Articles can contain sections (chapters of a long post), and sections can contain articles (a "Latest news" section holding several stories).

Common mistake

Using <section> as a fancy div just to wrap things for styling. If the content has no natural heading and no theme of its own, it's not a section. A plain <div> is the honest choice for styling-only wrappers.

A complete semantic page

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Shamba Smart Blog</title>
  </head>
  <body>
    <header>
      <p><strong>Shamba Smart</strong>: farming tips for young farmers</p>
      <nav aria-label="Main">
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">Articles</a></li>
          <li><a href="#">About</a></li>
        </ul>
      </nav>
    </header>

    <main>
      <article>
        <h1>Starting a kitchen garden in a small space</h1>
        <p>Posted on <time datetime="2026-11-02">2 November 2026</time></p>
        <section>
          <h2>Choose your containers</h2>
          <p>Old buckets, sacks and jerrycans all work if you add drainage holes.</p>
        </section>
        <section>
          <h2>What to plant first</h2>
          <p>Sukuma wiki, spinach and spring onions grow quickly and need little space.</p>
        </section>
      </article>

      <aside>
        <h2>Related posts</h2>
        <ul>
          <li><a href="#">Making compost at home</a></li>
        </ul>
      </aside>
    </main>

    <footer>
      <p><small>&copy; 2026 Shamba Smart, Nakuru</small></p>
    </footer>
  </body>
</html>

Without CSS the page appears as a simple vertical document: site name, a bulleted menu, the article with its date and two sub-headings, the related posts list and the copyright line. The structure is ready for CSS to arrange into columns later, for example with CSS Grid.

Note

When a page has more than one <nav> (say, a main menu and a footer menu), give each a short aria-label such as "Main" or "Footer" so screen-reader users can tell them apart. Here the <aside> sits inside <main> because it relates to this article; a site-wide sidebar would usually sit outside <main>.

Other semantic elements

  • <figure> and <figcaption>: an image, diagram or code sample with a caption.
  • <time>: a date or time, with a machine-readable datetime.
  • <address>: contact information for the page or article author.
  • <details> and <summary>: a disclosure widget that opens and closes without JavaScript, great for FAQs.

Why it matters

  • Accessibility: landmarks let screen-reader users skip straight to the content they want.
  • Search engines: clear structure helps them identify the main content of a page.
  • Teamwork: <nav> is easier to find in a long file than <div class="nv-wrap2">.
  • Reader modes: browser reading views use <article> and <main> to find the text to show.

Key points

  • Semantic elements describe the role of content; CSS controls where it appears.
  • <header>, <nav>, <main>, <aside> and <footer> create landmarks that assistive technology can jump to.
  • Use one visible <main> per page.
  • An <article> makes sense on its own; a <section> is a themed part with a heading; a <div> is for styling only.
Up next · Structure & LayoutTablesPresent data in rows and columns.
→

Tip: use the ← and → keys to move between pages.