Skip to main content

HTML guides

Semantic HTML Tags

When to use header, nav, main, section, article, aside, and footer, and why those semantic HTML tags help accessibility, structure, and search.

TechWebster2 min readDiscussion on DEV (opens in a new tab)

When building web pages, HTML is not just about structure—it’s also about meaning.
This is where Semantic Tags come into play.

Semantic HTML helps both developers and browsers understand what each part of your webpage represents.


🧠 What Are Semantic Tags?

Semantic tags clearly describe their meaning in a human- and machine-readable way.

Example:

<header>This is the header</header>

Instead of using:

<div>This is the header</div>

👉 The first example is better because <header> tells us the purpose directly.


❌ Non-Semantic vs ✅ Semantic

Non-Semantic:

<div>
  <div>Logo</div>
  <div>Menu</div>
</div>

Semantic:

<header>
  <h1>Logo</h1>
  <nav>Menu</nav>
</header>

👉 Semantic HTML improves:

  • Code readability
  • SEO
  • Accessibility

🏗️ Common Semantic HTML Tags


1. 🧾 <header> — The Top Section

Represents the introductory content of a page or section.

Example:

<header>
  <h1>My Website</h1>
  <p>Welcome to my blog</p>
</header>

Used for menus or navigation links.

Example:

<nav>
  <a href="#">Home</a>
  <a href="#">About</a>
  <a href="#">Contact</a>
</nav>

3. 📄 <main> — Main Content Area

Contains the primary content of the page.

Rule:

👉 Only one <main> per page

Example:

<main>
  <h2>Latest Articles</h2>
  <p>This is the main content area</p>
</main>

4. 📦 <section> — Grouped Content

Used to group related content together.

Example:

<section>
  <h2>Our Services</h2>
  <p>We provide web development services</p>
</section>

5. 📰 <article> — Independent Content

Represents content that can stand on its own.

Example:

<article>
  <h2>Blog Title</h2>
  <p>This is a blog post</p>
</article>

Use Cases:

  • Blog posts
  • News articles
  • Product cards

6. 📌 <aside> — Side Content

Used for extra or related content.

Example:

<aside>
  <h3>Related Posts</h3>
  <p>Check out these articles</p>
</aside>

Represents the footer of a page or section.

Example:

<footer>
  <p>© 2026 My Website</p>
</footer>

A page wireframe fills in: header, nav, main, aside, and footer.headernavmainasidefooter

🧩 Full Page Example (Real Layout)

<!DOCTYPE html>
<html>
<head>
  <title>Semantic Page</title>
</head>
<body>

  <header>
    <h1>My Website</h1>
  </header>

  <nav>
    <a href="#">Home</a>
    <a href="#">Services</a>
  </nav>

  <main>
    <section>
      <h2>About Us</h2>
      <p>We build websites</p>
    </section>

    <article>
      <h2>Latest Blog</h2>
      <p>This is a blog post</p>
    </article>

    <aside>
      <h3>Tips</h3>
      <p>Use semantic HTML!</p>
    </aside>
  </main>

  <footer>
    <p>© 2026 My Website</p>
  </footer>

</body>
</html>

🎯 Why Semantic HTML Is Important

1. 🔍 SEO (Search Engine Optimization)

Search engines understand your content better.


2. ♿ Accessibility

Screen readers can interpret your page correctly.


3. 👨‍💻 Clean Code

Makes your code easier to read and maintain.


4. 🧩 Better Structure

Gives a logical layout to your webpage.


🎤 Interview Questions & Answers

Q1: What are semantic HTML tags?

A: Tags that clearly describe their meaning and purpose.


Q2: Give examples of semantic tags.

A: <header>, <nav>, <main>, <section>, <article>, <footer>


Q3: Difference between <section> and <article>?

A:

  • <section> → Groups related content
  • <article> → Independent, reusable content

A: Yes, inside different sections or articles.


Q5: Why not use <div> everywhere?

A: <div> has no meaning, while semantic tags improve SEO and accessibility.


💡 Pro Tips for Students

  • Always use <main> only once
  • Prefer <section> over <div> when possible
  • Use <article> for reusable content
  • Combine semantic tags for better structure
  • Think: "What does this content represent?" before choosing a tag

🚀 Final Thoughts

Semantic HTML is a small change that makes a big difference.

It helps you:

  • Write professional code
  • Build accessible websites
  • Improve SEO rankings

👉 Mastering semantic tags is a must for every web developer.

Build with us

Need this shipped, not just studied?

TechWebster designs and builds websites and web apps, with the markup, performance, and search setup included from the first commit.