Web Development /HTML — Building Web Pages / Lesson
Web Development

HTML Semantic Elements and Page Structure

📖

Lesson Content

HTML

Introduction to Semantic HTML

As webpages become larger and more complex, developers need a clear way to
describe what different parts of a page mean.

HTML provides semantic elements that communicate the purpose
of different sections of a webpage.

For example, a developer can use <header> for introductory
content, <nav> for navigation, <main>
for the primary content, <article> for independent content,
and <footer> for footer information.

Semantic HTML makes websites easier for browsers, search engines, developers,
and assistive technologies to understand.


1. What Does Semantic Mean?

The word semantic relates to meaning.

A semantic HTML element tells us something about the meaning or purpose of
the content inside it.

Example

<nav>
    <a href="/">Home</a>
    <a href="/courses">Courses</a>
    <a href="/contact">Contact</a>
</nav>

The <nav> element tells the browser that the links represent
a navigation area.


2. Semantic vs Non-Semantic Elements

Some HTML elements clearly communicate their purpose, while others are generic.

Semantic Elements

  • <header>
  • <nav>
  • <main>
  • <section>
  • <article>
  • <aside>
  • <footer>
  • <figure>
  • <figcaption>
  • <time>
  • <address>

Generic Elements

  • <div>
  • <span>

Generic elements are still useful. However, when a more appropriate semantic
element exists, it is often better to use the semantic element.


3. The Header Element

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

A website header may contain:

  • Logo
  • Website name
  • Navigation
  • Search controls
  • Introductory information

Example

<header>

    <h1>Dwallnet Technologies</h1>

    <p>
        Technology Training and Talent Development
    </p>

</header>

A page can have a document-level header, and individual sections or articles
can also have their own introductory headers.


4. The Nav Element

The <nav> element represents a section containing important
navigation links.

Example

<nav>

    <a href="/">Home</a>

    <a href="/courses">
        Courses
    </a>

    <a href="/about">
        About
    </a>

    <a href="/contact">
        Contact
    </a>

</nav>

Not every group of links needs to be inside <nav>.
Use it for major navigation areas.


5. The Main Element

The <main> element represents the primary content of a document.

Example

<main>

    <h1>Web Development Course</h1>

    <p>
        Learn how to build modern websites.
    </p>

</main>

A document normally has one main content area.

Content that is repeated across multiple pages, such as a site-wide header,
navigation, or footer, generally does not belong inside the main content.


6. The Section Element

The <section> element represents a thematic grouping of content.

Example

<section>

    <h2>HTML Fundamentals</h2>

    <p>
        Learn the basic structure and syntax of HTML.
    </p>

</section>

A section will commonly have a heading that describes its purpose.

Multiple Sections

<main>

    <section>
        <h2>HTML</h2>
        <p>Learn webpage structure.</p>
    </section>

    <section>
        <h2>CSS</h2>
        <p>Learn webpage styling.</p>
    </section>

    <section>
        <h2>JavaScript</h2>
        <p>Learn webpage interactivity.</p>
    </section>

</main>

7. The Article Element

The <article> element represents a self-contained piece of content
that could potentially be distributed or understood independently.

Examples include:

  • Blog posts
  • News articles
  • Forum posts
  • Student testimonials
  • Product reviews
  • Course announcements

Example

<article>

    <h2>Why Learn Web Development?</h2>

    <p>
        Web development provides the skills needed to build websites
        and web applications.
    </p>

</article>

8. Section vs Article

These two elements are related but have different purposes.

Section

Use <section> when grouping related content into a thematic
part of a larger document.

Article

Use <article> when the content forms an independent,
self-contained unit.

Example

<section>

    <h2>Latest News</h2>

    <article>
        <h3>New Web Development Class</h3>
        <p>Registration is now open.</p>
    </article>

    <article>
        <h3>New Data Analysis Class</h3>
        <p>The next cohort begins soon.</p>
    </article>

</section>

9. The Aside Element

The <aside> element represents content that is related
to the surrounding content but is not the main focus.

Examples include:

  • Related articles
  • Helpful resources
  • Sidebar information
  • Author information
  • Course recommendations
  • Additional notes

Example

<aside>

    <h2>Related Courses</h2>

    <ul>
        <li>Data Analysis</li>
        <li>Cyber Security</li>
        <li>WordPress Development</li>
    </ul>

</aside>

10. The Footer Element

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

A website footer may contain:

  • Copyright information
  • Contact information
  • Social links
  • Secondary navigation
  • Legal information

Example

<footer>

    <p>
        &copy; 2026 Dwallnet Technologies.
    </p>

    <a href="/privacy">
        Privacy Policy
    </a>

</footer>

11. Figure and Figcaption

The <figure> element represents self-contained content,
often an image, diagram, chart, or illustration.

The <figcaption> element provides a caption for the figure.

Example

<figure>

    <img
        src="student.jpg"
        alt="Students attending a web development class"
    >

    <figcaption>
        Students during a practical web development session.
    </figcaption>

</figure>

The figure and caption form one meaningful unit.


12. The Time Element

The <time> element represents a specific time or date.

Example

<p>
    The next class starts on
    <time datetime="2026-10-05">
        October 5, 2026
    </time>.
</p>

The visible text is designed for people, while the datetime
value provides a machine-readable representation.


13. The Address Element

The <address> element is used for contact information
associated with a webpage, article, or organization.

Example

<address>

    Dwallnet Technologies<br>
    Agbor, Delta State, Nigeria<br>
    Email:
    <a href="mailto:info@example.com">
        info@example.com
    </a>

</address>

It should not be used simply because some text happens to be a physical address.
Its semantic purpose is contact information.


14. A Complete Semantic Page Structure

A modern webpage can combine semantic elements to create a clear document structure.

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta
        name="viewport"
        content="width=device-width, initial-scale=1.0"
    >

    <title>
        Dwallnet Web Development
    </title>

</head>

<body>

    <header>

        <h1>
            Dwallnet Technologies
        </h1>

        <nav>

            <a href="/">
                Home
            </a>

            <a href="/courses">
                Courses
            </a>

            <a href="/about">
                About
            </a>

            <a href="/contact">
                Contact
            </a>

        </nav>

    </header>


    <main>

        <section>

            <h2>
                Web Development
            </h2>

            <p>
                Learn how to build modern websites and web applications.
            </p>

        </section>


        <section>

            <h2>
                Latest Articles
            </h2>

            <article>

                <h3>
                    Introduction to HTML
                </h3>

                <p>
                    HTML provides the structure of webpages.
                </p>

            </article>


            <article>

                <h3>
                    Introduction to CSS
                </h3>

                <p>
                    CSS controls the visual presentation of webpages.
                </p>

            </article>

        </section>


        <aside>

            <h2>
                Related Courses
            </h2>

            <ul>

                <li>
                    Data Analysis
                </li>

                <li>
                    Cyber Security
                </li>

            </ul>

        </aside>

    </main>


    <footer>

        <p>
            &copy; 2026 Dwallnet Technologies.
        </p>

    </footer>

</body>

</html>

15. Why Semantic HTML Matters

Semantic HTML provides several important benefits.

Accessibility

Assistive technologies can use semantic structure to help users navigate
webpages more effectively.

SEO

Clear document structure can help search engines better understand the
organization and meaning of webpage content.

Maintainability

Developers can understand a page more easily when the HTML communicates
what each section represents.

Consistency

Semantic HTML establishes meaningful conventions for organizing content
across a website.


16. Semantic HTML and CSS

Semantic HTML does not prevent developers from creating custom designs.
CSS can style semantic elements just like generic elements.

header {
    padding: 20px;
}

nav {
    display: flex;
    gap: 20px;
}

main {
    max-width: 1200px;
    margin: auto;
}

section {
    margin-bottom: 40px;
}

aside {
    padding: 20px;
}

footer {
    padding: 30px;
}

The HTML communicates meaning while CSS controls presentation.


17. Semantic HTML and JavaScript

Semantic elements can also be selected and manipulated with JavaScript.

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

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

console.log(navigation);
console.log(articles);

This allows JavaScript to work with meaningful parts of the document.


18. Div vs Semantic Elements

The <div> element is a generic container.
It has no special semantic meaning by itself.

For example:

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

If the container represents the page or section header, a semantic alternative
may be more appropriate:

<header>
    ...
</header>

However, this does not mean that <div> should never be used.
There are many situations where a generic container is appropriate.


19. Span vs Semantic Elements

The <span> element is a generic inline container.

<p>
    Learn
    <span class="highlight">
        HTML
    </span>
    today.
</p>

It is commonly used when styling or manipulating a small piece of inline content.


20. Semantic Headings

Headings are also important to the structure of a webpage.

Use headings according to the hierarchy of the content.

<h1>Web Development</h1>

<h2>HTML</h2>

<h3>HTML Elements</h3>

<h3>HTML Attributes</h3>

<h2>CSS</h2>

<h3>Selectors</h3>

Do not choose heading levels simply because a particular size looks attractive.
CSS should control visual size.


21. Semantic Navigation Structure

A navigation area can contain a list of links.

<nav aria-label="Main navigation">

    <ul>

        <li>
            <a href="/">
                Home
            </a>
        </li>

        <li>
            <a href="/courses">
                Courses
            </a>
        </li>

        <li>
            <a href="/about">
                About
            </a>
        </li>

        <li>
            <a href="/contact">
                Contact
            </a>
        </li>

    </ul>

</nav>

The aria-label can help distinguish between multiple navigation
landmarks when a page contains more than one.


22. Nested Semantic Structures

Semantic elements can be nested when their relationships make sense.

<main>

    <section>

        <h2>
            Student Success Stories
        </h2>

        <article>

            <header>

                <h3>
                    From Beginner to Web Developer
                </h3>

            </header>

            <p>
                This article describes a student's learning journey.
            </p>

            <footer>

                <p>
                    Published in 2026
                </p>

            </footer>

        </article>

    </section>

</main>

Notice that an article can have its own header and footer.


23. Common Semantic HTML Mistakes

Mistake 1: Using Div for Everything

Instead of:

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

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

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

Consider using the semantic elements that accurately describe those areas.

<header>
    ...
</header>

<nav>
    ...
</nav>

<footer>
    ...
</footer>

Mistake 2: Using Section Without a Meaningful Purpose

Do not add <section> simply because you need a container.
Use it for a meaningful thematic grouping.

Mistake 3: Using Article for Every Container

An article should represent content that can reasonably stand on its own.

Mistake 4: Using Headings for Visual Size

Heading levels should represent content hierarchy. Use CSS when you want
a heading to appear larger or smaller.

Mistake 5: Multiple Main Elements

A document should have one primary <main> content area.


24. Semantic HTML and Accessibility

Semantic HTML is an important part of accessible web development.

It helps assistive technologies recognize meaningful regions of a page.

Important practices include:

  • Use <main> for primary content.
  • Use <nav> for major navigation.
  • Use meaningful headings.
  • Use appropriate semantic elements instead of unnecessary generic containers.
  • Use descriptive link text.
  • Use appropriate alternative text for meaningful images.
  • Use labels for form controls.
  • Use landmarks consistently.

25. Building a Real Website Structure

Consider a Dwallnet training website.

A possible structure could be:

<body>

    <header>
        Logo and primary navigation
    </header>

    <main>

        <section>
            Hero section
        </section>

        <section>
            Courses
        </section>

        <section>
            Student testimonials
        </section>

        <section>
            Latest articles
        </section>

        <aside>
            Related resources
        </aside>

    </main>

    <footer>
        Contact information and copyright
    </footer>

</body>

This structure gives developers and browsers a clear understanding of the
different areas of the page.


26. Practical Exercise

Build a semantic webpage for a technology training center.

Your webpage must contain:

  1. A semantic header.
  2. A navigation area.
  3. A main content area.
  4. At least three sections.
  5. At least two articles.
  6. An aside containing related information.
  7. A figure with an image and caption.
  8. A date using the time element.
  9. Contact information using address.
  10. A semantic footer.

Additional Requirements

  • Use meaningful headings.
  • Use proper HTML nesting.
  • Use CSS for visual styling.
  • Make the page responsive.
  • Use accessible navigation.
  • Do not use tables for layout.

27. Code Challenge

The following webpage uses generic containers everywhere.
Refactor it using appropriate semantic HTML elements.

<div class="site-header">

    <div class="logo">
        Dwallnet Technologies
    </div>

    <div class="menu">

        <a href="/">Home</a>
        <a href="/courses">Courses</a>
        <a href="/about">About</a>

    </div>

</div>


<div class="content">

    <div class="course-section">

        <h2>
            Web Development
        </h2>

        <div class="course-article">

            <h3>
                HTML Fundamentals
            </h3>

            <p>
                Learn the foundation of webpage structure.
            </p>

        </div>

    </div>


    <div class="sidebar">

        <h2>
            Related Courses
        </h2>

        <ul>
            <li>Data Analysis</li>
            <li>Cyber Security</li>
        </ul>

    </div>

</div>


<div class="site-footer">

    <p>
        &copy; 2026 Dwallnet Technologies.
    </p>

</div>

Challenge

Replace the generic containers with appropriate semantic elements while
preserving the content.

Corrected Version

<header>

    <div class="logo">
        Dwallnet Technologies
    </div>

    <nav aria-label="Main navigation">

        <a href="/">
            Home
        </a>

        <a href="/courses">
            Courses
        </a>

        <a href="/about">
            About
        </a>

    </nav>

</header>


<main>

    <section>

        <h2>
            Web Development
        </h2>

        <article>

            <h3>
                HTML Fundamentals
            </h3>

            <p>
                Learn the foundation of webpage structure.
            </p>

        </article>

    </section>


    <aside>

        <h2>
            Related Courses
        </h2>

        <ul>

            <li>
                Data Analysis
            </li>

            <li>
                Cyber Security
            </li>

        </ul>

    </aside>

</main>


<footer>

    <p>
        &copy; 2026 Dwallnet Technologies.
    </p>

</footer>

28. Lesson Summary

Semantic HTML allows developers to describe the meaning and purpose of
different parts of a webpage.

Important semantic elements include <header>,
<nav>, <main>,
<section>, <article>,
<aside>, and <footer>.

Additional semantic elements such as <figure>,
<figcaption>, <time>, and
<address> can provide additional meaning to content.

Semantic HTML improves accessibility, maintainability, document structure,
and the ability of software to interpret webpage content.

Generic elements such as <div> and <span>
remain useful when no more appropriate semantic element exists.


Key Principle


HTML should describe what content means, not simply how that content looks.

When you build webpages with meaningful semantic structure, you create a stronger
foundation for accessibility, SEO, CSS, JavaScript, WordPress, and modern
web application development.

Enjoying this lesson?

Sign in to your Dwallnet Academy student account to track your learning progress and mark lessons as complete.

Sign In to Track Progress