← Learning Hub
Beginner

Semantic Elements

Semantic elements describe their meaning, not just their look. Instead of using a plain <div> for everything, use elements that tell the browser what each part is.

A <div> is a plain box with no meaning - it's like a cardboard box with no label. A page built only from divs looks fine, but a search engine or a screen reader can't tell which box is the menu, which is the article and which is the footer.

Semantic elements are labelled boxes. They don't look different on their own (you still style them with CSS), but they give your page a clear meaning. This helps Google understand and rank your page, helps blind visitors navigate, and makes your own code easier to read months later.

  • <header> - the top of a page or section, often with a logo and menu.
  • <nav> - a group of navigation links.
  • <main> - the main content; use it once per page.
  • <article> - a complete piece, such as a blog post or product card.
  • <footer> - the bottom area, often with contact and copyright details.
Example
<!DOCTYPE html>
<html>
  <body>
    <header>
      <h1>Ravi's Blog</h1>
      <nav><a href="#">Home</a> | <a href="#">About</a></nav>
    </header>
    <main>
      <article>
        <h2>My First Trek</h2>
        <p>Last winter I walked to the top of a hill near my village...</p>
      </article>
    </main>
    <footer>
      <p>Written by Ravi, 2026</p>
    </footer>
  </body>
</html>
▶ Try it yourself
Semantic HTML helps search engines rank your page and helps people using screen readers jump straight to the main content.
Key points
  • Semantic elements describe what content is: header, nav, main, article, footer.
  • They help SEO, accessibility and readable code.
  • Use <div> only when no semantic element fits.

📝 Test yourself

1. Which element should hold the main content of a page?
2. Why use semantic elements?
3. Fill in the element for a group of navigation links:
<>