Nextgen Blog
HomeLearnAIQuantumRoboticsSecuritySpaceAbout
Nextgen Blog

By Anubhav — full stack engineer, IIT Mandi CSE. Deep dives into AI, software engineering, and the technologies shaping the next generation of tech.

Navigate

  • Home
  • Learn
  • Blog
  • Archive
  • About

Topics

  • Artificial Intelligence
  • Quantum Computing
  • Robotics
  • Cybersecurity
  • Space Tech

Connect

Built with ❤️ & By - Anubhav

© 2026 Nextgen Blog by Anubhav. All rights reserved.

Privacy PolicyTerms of Service
Phase 03 · Semantic Architecture & SEOChapter 12 of 18
11.
Phase 03Read time ~17 minDifficulty beginner

Semantic HTML

Semantic HTML is one of the most important concepts in modern, professional HTML.

In this chapter
  • 01What Is Semantic HTML?
  • 02Semantic vs Non-Semantic HTML
  • 03Non-semantic
  • 04Semantic
  • 05Why Semantic HTML Matters
  • 06Accessibility
  • 07SEO
  • 08Maintainability
  • 09Consistency
  • 10Better browser semantics
  • 11Main Semantic Elements
  • 12<header>
  • 13Important: Header Isn't Always the Website Header
  • 14<nav>
  • 15Does Every Link Need <nav>?
  • 16Multiple <nav> Elements
  • 17<main>
  • 18<main> Should Represent the Main Content
  • 19One Main Content Region
  • 20<section>
  • 21Sections Usually Have a Heading
  • 22<section> Is Not Just a Styled <div>
  • 23<article>
  • 24Multiple Articles
  • 25<article> Can Contain <header> and <footer>
  • 26<aside>
  • 27<aside> Doesn't Always Mean Sidebar
  • 28<footer>
  • 29Complete Semantic Page
  • 30Visualizing the DOM Structure
  • 31Semantic HTML and Accessibility
  • 32<div> vs Semantic Elements
  • 33<div>
  • 34<section>
  • 35<article>
  • 36<aside>
  • 37Decision Tree
  • 38<section> vs <article>
  • 39Can an Article Contain Sections?
  • 40Can a Section Contain Articles?
  • 41<figure> and <figcaption>
  • 42<address>
  • 43<time>
  • 44Why Machine-Readable Dates Matter
  • 45Semantic HTML and SEO
  • 46Semantic HTML and CSS
  • 47Semantic HTML and JavaScript
  • 48Bad Semantic HTML
  • 49Better Semantic HTML
  • 50Semantic HTML Doesn't Mean "Never Use Div"
  • 51Professional Page Architecture
  • 52Semantic HTML Example — E-Commerce
  • 53Semantic HTML Example — Blog
  • 54Semantic HTML Checklist
  • 55Page structure
  • 56Content
  • 57Navigation
  • 58Headings
  • 59Media
  • 60Dates
  • 61Semantic Elements Cheat Sheet
  • 62Interview Questions
  • 63Q1. What is semantic HTML?
  • 64Q2. Why is semantic HTML important?
  • 65Q3. What is the difference between <div> and <section>?
  • 66Q4. What is the difference between <section> and <article>?
  • 67Q5. Can an article contain a section?
  • 68Q6. Can a section contain articles?
  • 69Q7. Is <header> only for the top of a webpage?
  • 70Q8. Is <footer> only for the bottom of the webpage?
  • 71Q9. Does every link need to be inside <nav>?
  • 72Q10. Should we completely avoid <div>?
  • 73Mini Project — Semantic Blog Page
  • 74Chapter 10 — Final Mental Model
  • 75The core principle:
  • 76Next Chapter
  • 77Chapter 11 — HTML Page Architecture
In this chapter (77 sections)
01What Is Semantic HTML?02Semantic vs Non-Semantic HTML03Non-semantic04Semantic05Why Semantic HTML Matters06Accessibility07SEO08Maintainability09Consistency10Better browser semantics11Main Semantic Elements12<header>13Important: Header Isn't Always the Website Header14<nav>15Does Every Link Need <nav>?16Multiple <nav> Elements17<main>18<main> Should Represent the Main Content19One Main Content Region20<section>21Sections Usually Have a Heading22<section> Is Not Just a Styled <div>23<article>24Multiple Articles25<article> Can Contain <header> and <footer>26<aside>27<aside> Doesn't Always Mean Sidebar28<footer>29Complete Semantic Page30Visualizing the DOM Structure31Semantic HTML and Accessibility32<div> vs Semantic Elements33<div>34<section>35<article>36<aside>37Decision Tree38<section> vs <article>39Can an Article Contain Sections?40Can a Section Contain Articles?41<figure> and <figcaption>42<address>43<time>44Why Machine-Readable Dates Matter45Semantic HTML and SEO46Semantic HTML and CSS47Semantic HTML and JavaScript48Bad Semantic HTML49Better Semantic HTML50Semantic HTML Doesn't Mean "Never Use Div"51Professional Page Architecture52Semantic HTML Example — E-Commerce53Semantic HTML Example — Blog54Semantic HTML Checklist55Page structure56Content57Navigation58Headings59Media60Dates61Semantic Elements Cheat Sheet62Interview Questions63Q1. What is semantic HTML?64Q2. Why is semantic HTML important?65Q3. What is the difference between <div> and <section>?66Q4. What is the difference between <section> and <article>?67Q5. Can an article contain a section?68Q6. Can a section contain articles?69Q7. Is <header> only for the top of a webpage?70Q8. Is <footer> only for the bottom of the webpage?71Q9. Does every link need to be inside <nav>?72Q10. Should we completely avoid <div>?73Mini Project — Semantic Blog Page74Chapter 10 — Final Mental Model75The core principle:76Next Chapter77Chapter 11 — HTML Page Architecture

So far, we've learned how to create:

  • Text
  • Links
  • Images
  • Lists
  • Tables
  • Forms
  • Validation

Now we're going to learn how to give the page's content meaning and structure.


1. What Is Semantic HTML?#

The word semantic means:

Something that has meaning.

Semantic HTML uses HTML elements that describe what the content represents, rather than simply describing how it should look.

For example:

<div>
    Navigation
</div>

works technically, but doesn't tell the browser what that content actually is.

Instead:

<nav>
    Navigation
</nav>

communicates:

"This is navigation."


2. Semantic vs Non-Semantic HTML#

Non-semantic#

<div class="header">
    ...
</div>
 
<div class="navigation">
    ...
</div>
 
<div class="content">
    ...
</div>
 
<div class="footer">
    ...
</div>

The browser sees several generic containers.

Semantic#

<header>
    ...
</header>
 
<nav>
    ...
</nav>
 
<main>
    ...
</main>
 
<footer>
    ...
</footer>

Now the structure communicates meaning.


3. Why Semantic HTML Matters#

Semantic HTML provides several benefits.

1. Accessibility#

Assistive technologies can understand the page structure better.

2. SEO#

Search engines can better understand the roles and relationships of content.

3. Maintainability#

Developers can understand the code more easily.

4. Consistency#

A page has a predictable structure.

5. Better browser semantics#

The browser understands what different regions represent.

Think:

Semantic HTML
      │
      ├── Accessibility
      ├── SEO
      ├── Maintainability
      └── Clear structure

4. Main Semantic Elements#

The most important page-level semantic elements are:

<header>
<nav>
<main>
<section>
<article>
<aside>
<footer>

A typical page might look like:

┌──────────────────────────────────────┐
│              HEADER                  │
│ Logo + Website Title                 │
└──────────────────────────────────────┘
┌──────────────────────────────────────┐
│               NAV                    │
│ Home | About | Blog | Contact        │
└──────────────────────────────────────┘
┌──────────────────────────────────────┐
│                                      │
│               MAIN                   │
│                                      │
│  ┌──────────────────────────────┐    │
│  │          ARTICLE             │    │
│  │                              │    │
│  │      Blog Post               │    │
│  └──────────────────────────────┘    │
│                                      │
│  ┌──────────────┐                    │
│  │    ASIDE     │                    │
│  │ Related Posts│                    │
│  └──────────────┘                    │
│                                      │
└──────────────────────────────────────┘
┌──────────────────────────────────────┐
│              FOOTER                  │
└──────────────────────────────────────┘

Let's understand each element.


5. <header>#

<header> represents introductory content for a page or section.

Example:

<header>
    <h1>NextGen Blog</h1>
    <p>Latest technology and AI news</p>
</header>

A header can contain:

  • Logo
  • Heading
  • Introduction
  • Navigation
  • Search
  • Author information

6. Important: Header Isn't Always the Website Header#

This is a common misconception.

<header> can belong to the entire page:

<body>
 
    <header>
        <h1>My Blog</h1>
    </header>
 
</body>

But it can also belong to an article:

<article>
 
    <header>
        <h2>Understanding Kubernetes</h2>
        <p>Published on October 1, 2026</p>
    </header>
 
    ...
</article>

So:

<header>
    ↓
introductory content

not necessarily:

<header>
    ↓
website top bar only

7. <nav>#

<nav> represents a section containing navigation links.

Example:

<nav>
    <a href="/">Home</a>
    <a href="/about">About</a>
    <a href="/blog">Blog</a>
    <a href="/contact">Contact</a>
</nav>

A more structured version:

<nav aria-label="Main navigation">
 
    <ul>
 
        <li>
            <a href="/">Home</a>
        </li>
 
        <li>
            <a href="/about">About</a>
        </li>
 
        <li>
            <a href="/blog">Blog</a>
        </li>
 
        <li>
            <a href="/contact">Contact</a>
        </li>
 
    </ul>
 
</nav>

8. Does Every Link Need <nav>?#

No.

This is an important semantic distinction.

Suppose you have:

<p>
    Read our
    <a href="/privacy">Privacy Policy</a>.
</p>

That doesn't necessarily need:

<nav>

<nav> is intended for major navigation blocks.

Examples:

Main navigation
Table of contents
Pagination navigation
Previous/next article navigation

Not every individual link.


9. Multiple <nav> Elements#

A page can contain multiple navigation sections.

For example:

<nav aria-label="Main navigation">
    ...
</nav>
 
<nav aria-label="Table of contents">
    ...
</nav>
 
<nav aria-label="Pagination">
    ...
</nav>

The aria-label helps distinguish their purposes when there are multiple navigation landmarks.


10. <main>#

<main> represents the dominant content of the document.

Example:

<main>
 
    <h1>HTML Tutorial</h1>
 
    <p>
        Learn HTML from beginner to advanced.
    </p>
 
</main>

Think:

<header>
    Site introduction
</header>
 
<nav>
    Navigation
</nav>
 
<main>
    Primary content
</main>
 
<footer>
    Footer information
</footer>

11. <main> Should Represent the Main Content#

Suppose you're on a blog article:

Header
Navigation
Sidebar
Blog article
Footer

The blog article is likely the primary content.

So:

<main>
 
    <article>
        ...
    </article>
 
</main>

12. One Main Content Region#

A document generally has one main content region.

Typical structure:

<body>
 
    <header>
        ...
    </header>
 
    <nav>
        ...
    </nav>
 
    <main>
        ...
    </main>
 
    <footer>
        ...
    </footer>
 
</body>

Don't use <main> repeatedly simply as a generic container.


13. <section>#

<section> represents a thematic grouping of content.

Example:

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

Think:

<section>
    = a meaningful topic/group

14. Sections Usually Have a Heading#

A good section generally has a heading.

Example:

<section>
 
    <h2>Latest Articles</h2>
 
    ...
 
</section>

Another:

<section>
 
    <h2>Customer Reviews</h2>
 
    ...
 
</section>

Another:

<section>
 
    <h2>Pricing</h2>
 
    ...
 
</section>

This makes the document structure easier to understand.


15. <section> Is Not Just a Styled <div>#

This is a common mistake.

Bad:

<section>
    <div>Red box</div>
</section>
 
<section>
    <div>Blue box</div>
</section>

If the sections don't represent meaningful thematic groups, <section> may not be appropriate.

Sometimes:

<div>

is actually the correct element.

Remember:

<div>
→ generic container
 
<section>
→ meaningful thematic grouping

16. <article>#

<article> represents self-contained content that could potentially stand on its own.

Examples:

  • Blog post
  • News article
  • Forum post
  • Product review
  • Comment
  • User-generated post

Example:

<article>
 
    <h2>What Is Kubernetes?</h2>
 
    <p>
        Kubernetes is a container orchestration platform...
    </p>
 
</article>

17. Multiple Articles#

A blog page might contain:

<main>
 
    <h1>Latest Articles</h1>
 
    <article>
        <h2>Introduction to AI Agents</h2>
        <p>...</p>
    </article>
 
    <article>
        <h2>Understanding Kubernetes</h2>
        <p>...</p>
    </article>
 
    <article>
        <h2>What Is RAG?</h2>
        <p>...</p>
    </article>
 
</main>

Each article represents an independent piece of content.


18. <article> Can Contain <header> and <footer>#

Example:

<article>
 
    <header>
 
        <h2>Understanding RAG</h2>
 
        <p>
            Published October 1, 2026
        </p>
 
    </header>
 
    <p>
        Retrieval-Augmented Generation combines
        retrieval with language models.
    </p>
 
    <footer>
 
        <p>
            Author: Anubhav
        </p>
 
    </footer>
 
</article>

This is a perfectly valid semantic structure.


19. <aside>#

<aside> represents content that is indirectly related to the main content.

Examples:

  • Sidebar
  • Related articles
  • Author information
  • Advertisements
  • Tips
  • Supporting information

Example:

<aside>
 
    <h2>Related Articles</h2>
 
    <ul>
        <li>
            <a href="/html">Learn HTML</a>
        </li>
 
        <li>
            <a href="/css">Learn CSS</a>
        </li>
    </ul>
 
</aside>

20. <aside> Doesn't Always Mean Sidebar#

Another common misconception:

aside = sidebar

Not necessarily.

For example:

<article>
 
    <h1>HTML Forms</h1>
 
    <p>...</p>
 
    <aside>
        <p>
            Tip: Always associate labels with controls.
        </p>
    </aside>
 
    <p>...</p>
 
</article>

Here the <aside> is related to the article but not part of its primary flow.


21. <footer>#

<footer> represents footer information for a page or section.

Example:

<footer>
 
    <p>
        © 2026 NextGen Blog
    </p>
 
</footer>

But just like <header>, <footer> isn't restricted to the entire webpage.

An article can have a footer:

<article>
 
    <h2>HTML Semantic Elements</h2>
 
    <p>...</p>
 
    <footer>
        <p>Author: Anubhav</p>
    </footer>
 
</article>

22. Complete Semantic Page#

Let's combine everything.

<!DOCTYPE html>
<html lang="en">
 
<head>
 
    <meta charset="UTF-8">
 
    <meta
        name="viewport"
        content="width=device-width, initial-scale=1.0"
    >
 
    <title>NextGen Blog</title>
 
</head>
 
<body>
 
    <header>
 
        <h1>NextGen Blog</h1>
 
        <p>
            Technology, AI and software development
        </p>
 
    </header>
 
    <nav aria-label="Main navigation">
 
        <ul>
 
            <li>
                <a href="/">Home</a>
            </li>
 
            <li>
                <a href="/ai">AI</a>
            </li>
 
            <li>
                <a href="/programming">Programming</a>
            </li>
 
            <li>
                <a href="/about">About</a>
            </li>
 
        </ul>
 
    </nav>
 
    <main>
 
        <section>
 
            <h2>Latest Articles</h2>
 
            <article>
 
                <header>
 
                    <h3>
                        Understanding AI Agents
                    </h3>
 
                    <p>
                        Published October 1, 2026
                    </p>
 
                </header>
 
                <p>
                    AI agents can perform tasks rather than
                    simply answering questions.
                </p>
 
                <footer>
 
                    <p>
                        Author: Anubhav
                    </p>
 
                </footer>
 
            </article>
 
            <article>
 
                <header>
 
                    <h3>
                        Introduction to Kubernetes
                    </h3>
 
                    <p>
                        Published October 1, 2026
                    </p>
 
                </header>
 
                <p>
                    Kubernetes helps manage containerized
                    applications at scale.
                </p>
 
                <footer>
 
                    <p>
                        Author: Anubhav
                    </p>
 
                </footer>
 
            </article>
 
        </section>
 
        <aside>
 
            <h2>Popular Articles</h2>
 
            <ul>
 
                <li>
                    <a href="/html">
                        Complete HTML Guide
                    </a>
                </li>
 
                <li>
                    <a href="/rag">
                        Understanding RAG
                    </a>
                </li>
 
            </ul>
 
        </aside>
 
    </main>
 
    <footer>
 
        <p>
            © 2026 NextGen Blog
        </p>
 
        <nav aria-label="Footer navigation">
 
            <a href="/privacy">
                Privacy
            </a>
 
            <a href="/terms">
                Terms
            </a>
 
        </nav>
 
    </footer>
 
</body>
 
</html>

23. Visualizing the DOM Structure#

The browser can conceptually represent that page as:

html
│
├── head
│
└── body
    │
    ├── header
    │   ├── h1
    │   └── p
    │
    ├── nav
    │   └── ul
    │       ├── li
    │       ├── li
    │       ├── li
    │       └── li
    │
    ├── main
    │   │
    │   ├── section
    │   │   │
    │   │   ├── h2
    │   │   │
    │   │   ├── article
    │   │   │   ├── header
    │   │   │   ├── p
    │   │   │   └── footer
    │   │   │
    │   │   └── article
    │   │
    │   └── aside
    │
    └── footer
        └── nav

This is much easier to understand than:

div
 ├── div
 ├── div
 ├── div
 │   ├── div
 │   └── div
 └── div

24. Semantic HTML and Accessibility#

Semantic HTML creates useful landmarks.

Common landmarks include:

<header>
<nav>
<main>
<aside>
<footer>

Assistive technologies can use these structural regions to help users navigate the page.

For example, a screen-reader user can understand:

Navigation
Main content
Complementary content
Footer

without having to read every element sequentially.


25. <div> vs Semantic Elements#

This is one of the most important HTML interview topics.

<div>#

Use when you need a generic container and no more meaningful semantic element applies.

<div class="card">
    ...
</div>

<section>#

Use when the content forms a meaningful thematic section.

<section>
    <h2>Our Services</h2>
    ...
</section>

<article>#

Use when the content is independently distributable/self-contained.

<article>
    <h2>How RAG Works</h2>
    ...
</article>

<aside>#

Use for tangential/supporting content.

<aside>
    Related Articles
</aside>

26. Decision Tree#

When deciding what element to use:

What is this content?
        │
        ├── Independent content?
        │       ↓
        │    <article>
        │
        ├── Thematic section?
        │       ↓
        │    <section>
        │
        ├── Supporting/tangential content?
        │       ↓
        │    <aside>
        │
        ├── Navigation?
        │       ↓
        │    <nav>
        │
        └── No meaningful semantic role?
                ↓
              <div>

This is a very useful mental model.


27. <section> vs <article>#

This confuses many beginners.

Consider a blog homepage:

Latest Articles
 
Article 1
Article 2
Article 3

A reasonable structure:

<section>
 
    <h2>Latest Articles</h2>
 
    <article>
        Article 1
    </article>
 
    <article>
        Article 2
    </article>
 
    <article>
        Article 3
    </article>
 
</section>

Think:

section
   ↓
group of related content
 
article
   ↓
individual self-contained content

28. Can an Article Contain Sections?#

Absolutely.

Example:

<article>
 
    <h1>Understanding Kubernetes</h1>
 
    <section>
 
        <h2>What Is Kubernetes?</h2>
 
        <p>...</p>
 
    </section>
 
    <section>
 
        <h2>Why Use Kubernetes?</h2>
 
        <p>...</p>
 
    </section>
 
    <section>
 
        <h2>How Kubernetes Works</h2>
 
        <p>...</p>
 
    </section>
 
</article>

This gives a strong semantic hierarchy.


29. Can a Section Contain Articles?#

Yes.

<section>
 
    <h2>Latest News</h2>
 
    <article>
        News article 1
    </article>
 
    <article>
        News article 2
    </article>
 
</section>

Very common for:

  • Blogs
  • News sites
  • Product listings
  • Reviews
  • Forums

30. <figure> and <figcaption>#

We encountered these in the Images chapter.

They're also semantic elements.

Example:

<figure>
 
    <img
        src="kubernetes.png"
        alt="Kubernetes architecture diagram"
    >
 
    <figcaption>
        Basic Kubernetes architecture
    </figcaption>
 
</figure>

<figure> represents self-contained content such as:

  • Image
  • Diagram
  • Chart
  • Code example
  • Illustration

And:

<figcaption>

provides its caption.


31. <address>#

<address> represents contact information for the relevant page or article author/owner.

Example:

<address>
 
    Contact:
    <a href="mailto:hello@example.com">
        hello@example.com
    </a>
 
</address>

For an article:

<article>
 
    <h1>Understanding HTML</h1>
 
    <address>
        By Anubhav Chaudhary
    </address>
 
    ...
</article>

Important:

<address> is not simply a generic element for displaying any postal address.

Its semantic purpose is contact information.


32. <time>#

<time> represents dates, times, or durations.

Example:

<time datetime="2026-10-01">
    October 1, 2026
</time>

The human-readable text is:

October 1, 2026

while:

datetime="2026-10-01"

provides machine-readable information.


33. Why Machine-Readable Dates Matter#

Consider:

<time datetime="2026-10-01">
    October 1, 2026
</time>

Humans see:

October 1, 2026

Machines can interpret:

2026-10-01

This is useful for:

  • Search engines
  • Browsers
  • Applications
  • Structured processing

34. Semantic HTML and SEO#

Semantic HTML can help search engines understand content structure.

Compare:

<div class="title">
    Best AI Tools
</div>

with:

<h1>
    Best AI Tools
</h1>

The second explicitly communicates:

This is the page's primary heading.

Similarly:

<article>

communicates that content represents an article.

Semantic HTML doesn't magically guarantee higher rankings, but it provides clearer machine-readable structure.


35. Semantic HTML and CSS#

Semantic HTML doesn't mean you cannot style it.

For example:

<header class="site-header">

can still have CSS.

.site-header {
    padding: 20px;
}

Semantic meaning and visual design are separate concepts.

Think:

HTML
 ↓
Meaning + Structure
 
CSS
 ↓
Presentation
 
JavaScript
 ↓
Behavior

36. Semantic HTML and JavaScript#

JavaScript can work with semantic elements just like other DOM elements.

Example:

const nav = document.querySelector("nav");

or:

const articles = document.querySelectorAll("article");

Semantic HTML therefore doesn't restrict JavaScript.

It improves the structure that JavaScript interacts with.


37. Bad Semantic HTML#

Consider:

<div class="header">
    <div class="logo">
        My Website
    </div>
 
    <div class="navigation">
        <div>Home</div>
        <div>About</div>
    </div>
</div>
 
<div class="main">
    <div class="article">
        ...
    </div>
</div>
 
<div class="footer">
    ...
</div>

Problems:

  • Generic elements everywhere
  • Poor semantics
  • Navigation isn't represented as navigation
  • Article isn't represented as an article
  • Main content isn't represented as main content

38. Better Semantic HTML#

<header>
 
    <a href="/">
        My Website
    </a>
 
    <nav aria-label="Main navigation">
 
        <ul>
 
            <li>
                <a href="/">Home</a>
            </li>
 
            <li>
                <a href="/about">About</a>
            </li>
 
        </ul>
 
    </nav>
 
</header>
 
<main>
 
    <article>
 
        <h1>My Article</h1>
 
        <p>
            Article content...
        </p>
 
    </article>
 
</main>
 
<footer>
 
    <p>
        © 2026 My Website
    </p>
 
</footer>

Much clearer.


39. Semantic HTML Doesn't Mean "Never Use Div"#

This is extremely important.

You should not try to replace every <div> with a semantic element.

If no meaningful semantic element exists:

<div>

is perfectly valid.

For example, a purely visual wrapper:

<div class="card-grid">
    ...
</div>

may appropriately remain a <div>.

The goal isn't:

Use zero divs.

The goal is:

Use the most appropriate semantic element when one exists.

40. Professional Page Architecture#

A modern page often looks like:

<body>
 
    <header>
        Site header
    </header>
 
    <nav>
        Main navigation
    </nav>
 
    <main>
 
        <section>
            Main topic
        </section>
 
        <section>
            Another topic
        </section>
 
        <aside>
            Supporting content
        </aside>
 
    </main>
 
    <footer>
        Site footer
    </footer>
 
</body>

But remember:

There is no single mandatory layout.

The correct semantic structure depends on the actual content.


41. Semantic HTML Example — E-Commerce#

Imagine an online store.

<header>
 
    <h1>NextGen Store</h1>
 
    <nav aria-label="Main navigation">
        ...
    </nav>
 
</header>
 
<main>
 
    <section>
 
        <h2>Featured Products</h2>
 
        <article>
 
            <h3>Wireless Headphones</h3>
 
            <p>₹4,999</p>
 
            <a href="/products/headphones">
                View Product
            </a>
 
        </article>
 
        <article>
 
            <h3>Smart Watch</h3>
 
            <p>₹8,999</p>
 
            <a href="/products/watch">
                View Product
            </a>
 
        </article>
 
    </section>
 
</main>
 
<footer>
    ...
</footer>

Each product can be represented as an <article> if it is treated as a self-contained item.


42. Semantic HTML Example — Blog#

<header>
 
    <h1>NextGen Blog</h1>
 
</header>
 
<nav aria-label="Main navigation">
    ...
</nav>
 
<main>
 
    <article>
 
        <header>
 
            <h1>What Are AI Agents?</h1>
 
            <p>
                Published:
                <time datetime="2026-10-01">
                    October 1, 2026
                </time>
            </p>
 
        </header>
 
        <section>
 
            <h2>Introduction</h2>
 
            <p>...</p>
 
        </section>
 
        <section>
 
            <h2>How AI Agents Work</h2>
 
            <p>...</p>
 
        </section>
 
        <footer>
 
            <address>
                Author: Anubhav
            </address>
 
        </footer>
 
    </article>
 
    <aside>
 
        <h2>Related Articles</h2>
 
        ...
 
    </aside>
 
</main>
 
<footer>
    ...
</footer>

This is a very strong semantic structure.


43. Semantic HTML Checklist#

When building a page, ask:

Page structure#

Do I have a header?
Do I have navigation?
Do I have a main content region?
Do I need an aside?
Do I have a footer?

Content#

Is this a section?
Is this an article?
Is this just a generic container?

Navigation#

Are important navigation links inside nav?

Headings#

Does each meaningful section have an appropriate heading?

Media#

Should this use figure/figcaption?

Dates#

Should this date use <time>?

44. Semantic Elements Cheat Sheet#

Element Meaning
<header> Introductory content
<nav> Navigation links
<main> Main content
<section> Thematic grouping
<article> Self-contained content
<aside> Related/supporting content
<footer> Footer information
<figure> Self-contained media/content
<figcaption> Figure caption
<address> Contact information
<time> Date/time

45. Interview Questions#

Q1. What is semantic HTML?#

HTML that uses elements according to their meaning and role rather than using generic containers for everything.


Q2. Why is semantic HTML important?#

It improves:

  • Accessibility
  • Document structure
  • Maintainability
  • Machine understanding
  • Potential SEO clarity

Q3. What is the difference between <div> and <section>?#

<div> is a generic container; <section> represents a meaningful thematic grouping.


Q4. What is the difference between <section> and <article>?#

A section groups related content around a theme; an article represents self-contained content that can potentially stand independently.


Q5. Can an article contain a section?#

Yes.

<article>
 
    <section>
        ...
    </section>
 
</article>

Q6. Can a section contain articles?#

Yes.

<section>
 
    <article>
        ...
    </article>
 
    <article>
        ...
    </article>
 
</section>

Q7. Is <header> only for the top of a webpage?#

No.

A <header> can also introduce an article or section.


Q8. Is <footer> only for the bottom of the webpage?#

No.

A <footer> can belong to a page, section, or article.


Q9. Does every link need to be inside <nav>?#

No.

<nav> is intended for significant navigation blocks, not every individual link.


Q10. Should we completely avoid <div>?#

No.

Use <div> when no more appropriate semantic element exists.


46. Mini Project — Semantic Blog Page#

Create a complete semantic blog page:

                    HEADER
              NextGen Blog Logo
 
                     NAV
        Home | AI | Programming | Cloud
 
                     MAIN
       ┌─────────────────────────────┐
       │                             │
       │          ARTICLE            │
       │                             │
       │  Understanding AI Agents    │
       │                             │
       │  Published: Oct 1, 2026     │
       │                             │
       │  ┌───────────────────────┐  │
       │  │ Introduction          │  │
       │  └───────────────────────┘  │
       │                             │
       │  ┌───────────────────────┐  │
       │  │ How Agents Work       │  │
       │  └───────────────────────┘  │
       │                             │
       └─────────────────────────────┘
 
                 ASIDE
             Related Articles
 
                    FOOTER
              © 2026 NextGen Blog

Try to build it without CSS.

The objective is to see the semantic structure in the HTML itself.


47. Chapter 10 — Final Mental Model#

Think of semantic HTML as describing a webpage to another developer, browser, search engine, and assistive technology without relying on visual appearance.

Instead of:

<div class="big-box">

say:

<main>

Instead of:

<div class="navigation">

say:

<nav>

Instead of:

<div class="blog-post">

say:

<article>

Instead of:

<div class="topic">

say:

<section>

But when the content has no special semantic meaning:

<div>

is completely fine.

The core principle:#

HTML should describe what content is, not merely how it looks.


Next Chapter#

Chapter 11 — HTML Page Architecture#

Next we'll take semantic HTML further and learn how to design the complete architecture of a professional HTML document:

  • Complete HTML document structure
  • <html>, <head>, <body>
  • Page hierarchy
  • Heading hierarchy
  • Landmark architecture
  • Header/navigation/main/footer relationships
  • Sections and nested sections
  • Articles and nested content
  • Multiple navigation regions
  • Breadcrumbs
  • Table of contents
  • Search areas
  • Skip links
  • Accessibility-oriented page structure
  • Real-world blog architecture
  • Real-world e-commerce architecture
  • Real-world dashboard architecture
  • Professional HTML page template
  • Common architecture mistakes
  • Interview questions

Finished this chapter?

Mark it as complete to track your mastery.

Previous ChapterChapter 9 — HTML Form ValidationNext ChapterChapter 11 — HTML Page Architecture
PrevNext