You are currently viewing Using <section>, <article>, <aside>, and <nav> Correctly

Using
,
,

In modern web development, semantic HTML plays a vital role in creating well-structured, accessible, and SEO-friendly websites. Unlike generic tags like <div> and <span>, semantic elements convey meaning about the content they enclose, helping both developers and browsers understand the structure and purpose of a webpage.

Among the most important semantic elements are <section>, <article>, <aside>, and <nav>. Using <section>, <article>, <aside>, and <nav> correctly ensures your content is logically organized, improves your site’s search engine ranking, and enhances accessibility for screen readers and assistive technologies. These tags make your HTML more readable, maintainable, and future-proof.

In this article, we’ll break down each of these elements, explain when and how to use them properly, highlight common mistakes, and provide practical examples. Whether you’re new to semantic HTML or need a refresher, this guide will help you use these tags with confidence and clarity.

If you are new to software engineering and would like to become a software developer, enroll in one of our software engineering course in Kenya. Our bootcamps are made to prepare you for the job market by providing industry-relevant skills. Sign up today and position yourself for a high-paying job in 10 – 12 months.

What Is Semantic HTML and Why It Matters

Semantic HTML refers to the use of HTML tags that clearly describe the meaning of the content they contain. Instead of relying solely on generic containers like <div> and <span>, semantic elements such as <header>, <section>, <article>, <aside>, and <nav> provide structure and context to web content.

Definition and Purpose of Semantic Elements

Semantic elements are designed to convey meaning about the content enclosed within them. For example:

  • <article> signals a standalone piece of content like a blog post or news story.
  • <section> denotes a thematic grouping of content.
  • <nav> identifies a navigation area.
  • <aside> highlights tangential or supporting content.

Their main purpose is to improve content clarity for developers, browsers, and assistive technologies.

Key Benefits

  • SEO Improvement: Search engines use semantic tags to better understand and index your content, leading to improved visibility in search results.
  • Accessibility: Screen readers rely on these tags to help users navigate a page more effectively, making your site more inclusive.
  • Code Readability & Maintenance: Developers (including your future self) can more easily understand and manage well-structured semantic HTML. 

Semantic vs. Non-Semantic Tags

Non-semantic tags like <div> and <span> don’t describe the content they contain they’re used purely for layout or styling. In contrast, semantic tags inherently describe the role of their content, making your markup more meaningful and organized.

Example:

<!-- Non-semantic -->

<div class="main-nav">...</div>

<!-- Semantic -->

<nav>...</nav>

By choosing semantic elements where appropriate, you’re not just writing HTML you’re communicating the intent of your content.

Understanding the <section> Element

The <section> element is a key part of semantic HTML used to define thematic groupings of related content. It’s meant to divide a webpage into meaningful chunks that can stand alone in the document outline.

Definition and When to Use <section>

A <section> represents a standalone segment of content that shares a common theme or purpose. It’s typically used for parts of a page like an introduction, features list, services, testimonials, or contact info.

Use <section> when:

  • The content has a clear heading or label.
  • It could logically appear in a table of contents.
  • It contributes to the overall outline of the document.

Best Practices: Thematic Grouping of Content

  • Always include a heading (<h1><h6>) inside a <section> to define its purpose.
  • Group related content that shares a function or topic.
  • Nest <section> only when necessary, and avoid overcomplicating the structure.

Common Mistakes to Avoid

  • Using <section> purely for layout: Don’t replace <div> with <section> unless the content is thematically grouped and meaningful.
  • Omitting a heading: A <section> without a heading fails to serve its semantic role.
  • Using <section> for unrelated blocks: Avoid grouping unrelated content just to reduce <div> usage.

Code Example: Correct Usage

<section>

  <h2>Our Services</h2>

  <p>We offer custom web development, SEO consulting, and design services.</p>

</section>

<section>

  <h2>Testimonials</h2>

  <blockquote>"This team transformed our online presence!" – A Happy Client</blockquote>

</section>

Each <section> above represents a clearly defined topic, is independently meaningful, and includes a heading, this is correct semantic usage.

Using the <article> Element Correctly

The <article> element is used to represent independent, self-contained content that can stand alone outside the context of the surrounding page. This makes it ideal for pieces like blog posts, news stories, user-submitted comments, and product cards.

Definition and Typical Use Cases

An <article> is best used for:

  • Blog posts
  • News stories
  • Forum posts
  • Product listings
  • User reviews or comments

Each <article> should be complete on its own and make sense even when syndicated or reused in other contexts (e.g., an RSS feed).

How It Differs from <section>

While both <article> and <section> are semantic elements used to organize content:

  • <article> is for stand-alone, self-contained content.
  • <section> is for grouping related content under a common theme.

Think of <article> as a reusable unit, and <section> as a way to structure or divide content logically within a document.

When to Nest <article> and <section>

  • <article> inside <section>: Use this when you have a section containing multiple related articles, like a “Latest Posts” section with individual <article>s.
  • <section> inside <article>: This works when a single article needs to be split into several themed sub-parts.

Code Snippet with Explanation

<section>

  <h2>Latest Blog Posts</h2>

  <article>

    <h3>Understanding Semantic HTML</h3>

    <p>Semantic HTML improves the clarity of your code and accessibility of your site...</p>

  </article>

  <article>

    <h3>Top 5 Web Design Trends in 2025</h3>

    <p>Stay ahead of the curve by learning the latest design trends influencing web development...</p>

  </article>

</section>

Explanation:

  • The outer <section> has a clear heading: “Latest Blog Posts.”
  • Inside, each <article> is an independent unit with its own heading and content.
  • Each <article> could be featured on its own and still make complete sense.

The Role of <aside> in Web Layouts

The <aside> element is used to mark content that is indirectly related to the main content of a page. It’s ideal for supplementary information like sidebars, tips, callouts, or contextual ads, anything that enhances or supports the main content but isn’t essential to understanding it.

What <aside> Is Meant For: Tangential or Complementary Content

Think of <aside> as a place for:

  • Related links or resources
  • Author bios
  • Pull quotes
  • Advertisements
  • Notes, tips, or disclaimers
  • Sidebar navigation

Its content is often secondary but still relevant to users who want to explore more or dive deeper.

Proper Use for Sidebars, Callouts, Tips, etc.

Use <aside> to:

  • Display additional content without distracting from the main narrative.
  • Highlight contextual info like “Pro Tips” or “Did You Know?” boxes.
  • Group related links or widgets in a sidebar layout.

Avoid using <aside> for unrelated tangents or layout containers. Its purpose is semantic, not purely visual.

Where to Place <aside> in Your Layout

  • Inside <article>: Use when the aside is related to the specific article like a note, quote, or reference within the story.
  • Outside <article> or <main>: Use when it supports the entire page like a global sidebar or advertisement relevant across all content.

Code Example for Context

<article>

  <h2>How to Improve Website Accessibility</h2>

  <p>Designing for accessibility means making your website usable for everyone, including people with disabilities...</p>

  <aside>

    <h3>Accessibility Tip</h3>

    <p>Always include descriptive alt text for images. This helps screen reader users understand your visual content.</p>

  </aside>

</article>

Explanation:

  • The <aside> here adds a relevant tip that complements the main article.
  • It enhances the reading experience without interrupting the main flow.

You could also have:

<main>

  <article>...</article>

</main>

<aside>

  <h2>Related Articles</h2>

  <ul>

    <li><a href="#">Building Semantic HTML Layouts</a></li>

    <li><a href="#">Top Accessibility Tools</a></li>

  </ul>

</aside>

In this layout, the <aside> offers global supplemental content to the whole page.

Proper Use of the <nav> Element

The <nav> element is used to define a block of navigation links typically menus or collections of internal links that help users navigate through a website or section of content.

Purpose of <nav> for Navigational Links

The primary role of <nav> is to enclose a set of major navigation links, such as:

  • Main site menus (e.g., Home, About, Contact)
  • Table of contents for a document
  • Pagination controls
  • In-page links for jumping between sections

It tells browsers, screen readers, and search engines: “This is navigation.”

When to Use <nav> vs. Anchor Links in Other Containers

Use <nav> when:

  • You are grouping primary or secondary site navigation.
  • The links are part of a structured menu or index.

Avoid <nav> for:

  • Inline anchor links within paragraphs or unrelated content.
  • Footer links or legal disclaimers unless they serve a navigational purpose.

Can You Have Multiple <nav> Elements?

Yes! You can use multiple <nav> elements on a single page. For example:

  • One for the main site navigation
  • One for section-specific links
  • One for breadcrumb navigation

Just be sure each serves a distinct purpose.

Best Practices for Accessibility

  • Use meaningful link text (avoid “Click here”).

Wrap your <nav> in a <header> or assign an ARIA label if you have more than one, like:

<nav aria-label="Main menu">...</nav>

<nav aria-label="Breadcrumb">...</nav>

Ensure keyboard navigation and screen readers can identify and skip to each <nav> element using landmarks.

Example of Semantic Navigation

<nav aria-label="Main navigation">

  <ul>

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

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

    <li><a href="/services">Services</a></li>

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

  </ul>

</nav>

Explanation:

  • The <nav> clearly contains a primary navigation menu.
  • The aria-label provides context for screen readers.
  • The unordered list keeps the navigation structured and accessible.

Common Mistakes and Misuses of Semantic Elements

Even experienced developers sometimes misuse semantic elements, which can lead to confusion, poor accessibility, or reduced SEO effectiveness. Below are some of the most frequent errors to watch out for when using <section>, <article>, <aside>, and <nav>.

1. Using <section> for Layout Purposes Only

Mistake: Using <section> like a <div> just to apply styles or layouts—without any thematic grouping or heading.

Correct:

<section>

  <h2>Features</h2>

  <p>Our app offers real-time collaboration and offline access.</p>

</section>

Incorrect:

<section class="wrapper">

  <div class="content-box">...</div>

</section>

If there’s no distinct theme or heading, use a <div> instead.

2. Nesting <article> Unnecessarily

Mistake: Placing one <article> inside another without good reason, leading to an overly complex and unclear structure.

Correct:

<article>

  <h2>5 Tips for Writing Clean Code</h2>

  <p>Clean code is easy to read and maintain...</p>

</article>

Incorrect:

<article>

  <article>

    <h3>Tip #1</h3>

    <p>Use meaningful names.</p>

  </article>

</article>

Use <section> or headings instead to break down an article into parts, don’t treat every subpart as a standalone article.

3. Overusing <aside> or Misplacing It

Mistake: Using <aside> for anything visually on the side, even if it has no semantic relevance to the content.

Correct:

<aside>

  <h3>Author Bio</h3>

  <p>Jane Doe is a front-end developer with 10 years of experience...</p>

</aside>

Incorrect:

<aside>

  <div class="banner">50% Off Today!</div>

</aside>

Only use <aside> for content related to or supporting the main page or article. If it’s purely decorative or promotional, consider a <div>.

4. Not Labeling Navigation Clearly in <nav>

Mistake: Having multiple <nav> elements with no ARIA labels, making them indistinguishable to screen readers.

Correct:

<nav aria-label="Main navigation">...</nav>

<nav aria-label="Footer navigation">...</nav>

Incorrect:

<nav>...</nav>

<nav>...</nav>

Without labels or context, users relying on assistive tech won’t know what each navigation block is for.

By avoiding these common pitfalls, your use of semantic HTML will be more effective, accessible, and maintainable.

Putting It All Together: A Sample Semantic HTML Layout

To wrap up, let’s look at a full example of a well-structured semantic HTML layout that uses <section>, <article>, <aside>, and <nav> correctly. This layout could represent a simple blog or news website.

Example: Complete Semantic HTML Structure

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <title>Semantic HTML Example</title>

</head>

<body>

  <header>

    <h1>My Web Journal</h1>

    <nav aria-label="Main navigation">

      <ul>

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

        <li><a href="/articles">Articles</a></li>

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

      </ul>

    </nav>

  </header>

  <main>

    <section>

      <h2>Latest Articles</h2>

      <article>

        <h3>Why Semantic HTML Matters</h3>

        <p>Semantic HTML improves structure, accessibility, and searchability...</p>

        <aside>

          <h4>Quick Tip</h4>

          <p>Use headings inside sections to improve outline structure.</p>

        </aside>

      </article>

      <article>

        <h3>Accessibility in Modern Web Design</h3>

        <p>Designing with accessibility in mind ensures inclusivity for all users...</p>

      </article>

    </section>

    <aside>

      <h2>Related Links</h2>

      <ul>

        <li><a href="#">HTML5 Elements Reference</a></li>

        <li><a href="#">ARIA Roles Guide</a></li>

      </ul>

    </aside>

  </main>

  <footer>

    <p>&copy; 2025 My Web Journal</p>

  </footer>

</body>

</html>

Brief Walkthrough

  • <nav>: Located in the <header>, clearly labeled and used for primary site navigation.
  • <section>: Groups the main content area (“Latest Articles”) under a common theme.
  • <article>: Each article stands alone with its own heading and content ideal for individual posts.
  • <aside> inside <article>: Provides a relevant tip that complements the article it’s inside.
  • Main <aside> (outside articles): Offers related links for broader context useful but not central to the main content.
  • The structure uses clear headings and preserves a logical, readable document outline for users and search engines.

This example shows how using semantic HTML properly can lead to better-organized, more accessible, and future-proof web pages.

To conclude, using <section>, <article>, <aside>, and <nav> correctly is more than just good practice, it’s essential for creating accessible, maintainable, and SEO-friendly websites. Semantic HTML provides structure and meaning to your content, making it easier for both users and machines to understand the purpose of each part of your page.

By avoiding common mistakes and following best practices, you can build cleaner, more intuitive layouts that improve user experience and enhance the clarity of your codebase. Whether you’re working on a simple blog or a complex web application, embracing semantic elements will make your development process more effective and future-proof.

Start implementing these elements thoughtfully in your next project, and you’ll quickly see the difference they make in both semantic html.

To begin your journey as a web developer, enroll in our web development course and begin making websites in less than 3 months. Get in touch via the contact form or the WhatsApp icon.

Leave a Reply