Special Offer Diwali Special Bundle Offer: 3 courses for ₹8,999, save ₹9,001 (50% OFF)! Limited seats available. View Bundles →
0% Completed
Tutorials / HTML Tutorial / Chapter 5: Modern HTML5, Media & Best Practices
HTML ⏱ 10 min read

Semantic HTML5 Elements

Writing semantic HTML means choosing tags that clearly describe their meaning to both the browser and developer, rather than filling pages with generic divs.

What is it?

Semantic elements clearly convey their purpose. Examples include `<header>`, `<nav>`, `<main>`, `<article>`, `<section>`, `<aside>`, and `<footer>`.

Why is it used?

Semantic HTML dramatically improves SEO ranking, accessibility for screen readers used by visually impaired users, and codebase maintainability.

Detailed Explanation

Before HTML5, developers wrote `<div id="header">`, `<div class="nav">`, `<div class="footer">`. HTML5 introduced semantic elements: • `<header>`: Introductory content or navigational links. • `<nav>`: Primary navigation section. • `<main>`: Central dominant content of the `<body>` (unique per page). • `<article>`: Self-contained composition (blog post, news story, comment). • `<section>`: Thematic grouping of content, typically with a heading. • `<aside>`: Content tangentially related to surrounding content (sidebar, related links). • `<footer>`: Author info, copyright, sitemap links.

Syntax Structure

Syntax Blueprint
<body>
  <header>...</header>
  <nav>...</nav>
  <main>
    <article>
      <section>...</section>
    </article>
    <aside>...</aside>
  </main>
  <footer>...</footer>
</body>

Code Example

HTML Code
<header>
  <h1>IGM Computer Institute</h1>
  <nav aria-label="Main Navigation">
    <a href="/">Home</a>
    <a href="/courses">Courses</a>
    <a href="/tutorial">Tutorials</a>
  </nav>
</header>

<main>
  <article>
    <h2>Why Learn Python in 2026?</h2>
    <p>Python continues to dominate AI, Machine Learning, and backend development.</p>
  </article>
  
  <aside>
    <h3>Upcoming Batches</h3>
    <p>Next KLiC Python batch starts on Monday.</p>
  </aside>
</main>

<footer>
  <p>&copy; 2026 IGM Computer Institute. All rights reserved.</p>
</footer>

Explanation of the Code

Each block expresses its structural role directly. Screen readers can instantly jump to `<main>` or `<nav>` without traversing hundreds of empty divs.

Expected Output

A semantically structured page that search engine crawlers can index with 100% clarity.

Real-World Application

Google penalizes non-semantic 'div-soup' websites in search ranking algorithms in favor of accessible semantic structures.

Common Mistakes to Avoid

• Wrapping entire pages in nested `<div>`s instead of using `<main>`, `<section>`, and `<article>`. • Having more than one `<main>` element visible on a single page.

Quick Practice Challenge

Refactor a page layout using `<header>`, `<nav>`, `<main>`, `<section>`, and `<footer>`.

Key Takeaways

• Semantic elements provide clear meaning to search engines and assistive technology. • Prefer `<article>`, `<section>`, `<nav>`, and `<main>` over generic `<div>` tags. • Only use `<div>` when no semantic element fits (purely for CSS styling wrappers).