TExcelTAD
Home › HTML › HTML Semantics

HTML Semantic Elements

A semantic element is one whose name describes its meaning. <div> and <span> say nothing about their content — they are generic boxes. <article>, <nav>, <time> or <figure>, on the other hand, tell browsers, search engines and assistive technology what the content is.

Compare these two snippets. They can look identical on screen:

html
<!-- non-semantic -->
<div class="header"><div class="nav">…</div></div>
<div class="content">…</div>
<div class="footer">…</div>

<!-- semantic -->
<header><nav>…</nav></header>
<main>…</main>
<footer>…</footer>

Why semantics matter

  • Accessibility: screen-reader users can jump between landmarks such as navigation, main content and footer, or list all articles on a page.
  • Search engines understand which parts of the page are primary content.
  • Readability: your HTML is easier for you and your team to understand than a "div soup".
  • Built-in behaviour: some semantic elements (<button>, <details>, <dialog>) work with the keyboard for free.

Structural elements

Element Meaning
<header> Introductory content for the page or for a section/article
<nav> Major navigation links
<main> The dominant content of the page (one per page)
<article> Self-contained content that makes sense on its own (post, comment, product)
<section> A thematic grouping, normally with a heading
<aside> Tangentially related content (sidebar, call-out)
<footer> Footer for the page or for a section/article
<figure> / <figcaption> A self-contained illustration with its caption

article or section?

Ask: would this make sense if it was published on its own somewhere else? If yes (a blog post, a news item, a user review) use <article>. If it is just one chapter of a larger whole ("Features", "Pricing") use <section>. Articles can contain sections, and sections can contain articles.

html · try it yourself
<!DOCTYPE html>
<html lang="en">
<head>
<style>
  body { font-family: sans-serif; max-width: 640px; margin: auto; padding: 8px; }
  header, footer { background: #f1f5f9; padding: 8px 12px; border-radius: 6px; }
  article { border: 1px solid #ddd; border-radius: 6px; padding: 12px; margin: 12px 0; }
  article header { background: none; padding: 0; }
  time { color: #666; font-size: 14px; }
</style>
</head>
<body>
  <header>
    <h1>Trail Notes</h1>
    <nav><a href="#">Home</a> · <a href="#">Hikes</a> · <a href="#">About</a></nav>
  </header>

  <main>
    <article>
      <header>
        <h2>Sunrise on Eagle Ridge</h2>
        <time datetime="2026-05-14">14 May 2026</time>
      </header>
      <p>We started at 4 a.m. and reached the ridge just as the sky turned pink.</p>
      <section>
        <h3>Comments</h3>
        <article><p><b>Mai:</b> Beautiful! Adding it to my list.</p></article>
      </section>
    </article>
  </main>

  <footer>Written by a hiker who likes HTML.</footer>
</body>
</html>

Inline semantic elements

Semantics are not only about big page regions:

Element Meaning
<time datetime="2026-12-31"> A date/time in machine-readable form
<mark> Highlighted text relevant to the current context (e.g. search hits)
<abbr title="…"> An abbreviation with its expansion
<strong> / <em> Strong importance / stress emphasis
<address> Contact information for the page or article author

figure and figcaption

<figure> wraps an image, diagram, code listing or chart together with its caption.

html · try it yourself
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif">
  <figure style="display: inline-block; margin: 0; border: 1px solid #ddd; padding: 8px; border-radius: 6px">
    <svg width="220" height="120" role="img" aria-label="Bar chart of visitors">
  <rect x="10"  y="70" width="40" height="40" fill="#fdba74"/>
  <rect x="65"  y="40" width="40" height="70" fill="#fb923c"/>
  <rect x="120" y="20" width="40" height="90" fill="#f97316"/>
  <rect x="175" y="50" width="40" height="60" fill="#ea580c"/>
</svg>
    <figcaption>Fig. 1 — Visitors per season</figcaption>
  </figure>
</body>
</html>

details and summary

<details> creates a collapsible widget with no JavaScript; <summary> is the clickable heading. It is keyboard-accessible out of the box.

html · try it yourself
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif">
  <h3>FAQ</h3>
  <details>
    <summary>Do I need to install anything?</summary>
    <p>No. Everything on this site runs in your browser.</p>
  </details>
  <details open>
    <summary>Is it free?</summary>
    <p>Yes. This one starts expanded because of the <code>open</code> attribute.</p>
  </details>
</body>
</html>

Tip: Pick elements by meaning, not by look. If you want bold text for decoration only, use CSS; use <strong> only when the text is genuinely important. Styling can always be changed with CSS — meaning cannot.

Test yourself

Which element best fits a single blog post that could be shared on its own?

  1. <section>
  2. <div>
  3. <article>
  4. <aside>

What is the main benefit of semantic elements over plain <div>s?

  1. They render faster
  2. They convey meaning to assistive technology and search engines
  3. They are required by CSS
  4. They add default colors

Which pair creates a collapsible section without JavaScript?

  1. <figure> + <figcaption>
  2. <details> + <summary>
  3. <header> + <footer>
  4. <dl> + <dt>