Falytom logoFALYTOM
Games
ToolsUI ComponentsServicesProductsAbout
LoginSign Up
menu
  1. Home
  2. /Web Development
  3. /Html
  4. /What Is Semantic Html
Your Progress0%
0 of 76 completed

Topics

Getting Started

  • What is HTML?
  • How the Web Works
  • Setting Up Your Environment
  • Your First HTML Page

HTML Document Structure

  • The DOCTYPE Declaration
  • The HTML Element
  • The Head Section
  • Meta Tags
  • The Body Element
  • HTML Comments

Text and Formatting

  • Headings (h1-h6)
  • Paragraphs
  • Line Breaks and Horizontal Rules
  • Text Formatting (Bold, Italic, etc.)
  • Quotations and Citations
  • Preformatted Text and Code
  • Subscript and Superscript

Links and Navigation

  • Creating Links
  • Absolute vs Relative URLs
  • Link Targets and Attributes
  • Email and Phone Links
  • Internal Page Links

Images and Media

  • Adding Images
  • Image Attributes
  • Image Formats
  • Figure and Figcaption
  • Responsive Images
  • Audio Elements
  • Video Elements
  • Embedding Content

Lists

  • Unordered Lists
  • Ordered Lists
  • Description Lists
  • Nested Lists

Tables

  • Table Basics
  • Table Headers and Footers
  • Spanning Columns and Rows
  • Table Captions
  • Styling Tables

Forms - Part 1 (Basics)

  • Introduction to Forms
  • Text Input Fields
  • Labels and Placeholders
  • Textarea Element
  • Checkboxes
  • Radio Buttons

Forms - Part 2 (Advanced)

  • Select Dropdowns
  • File Upload Inputs
  • HTML5 Input Types
  • Form Validation
  • Form Buttons
  • Fieldsets and Legends
  • Form Accessibility

Semantic HTML

  • What is Semantic HTML?
  • Header and Footer
  • Nav Element
  • Main and Article
  • Section and Aside
  • Div vs Semantic Elements
  • Time and Mark Elements

HTML5 Features

  • HTML5 Overview
  • Canvas Element
  • SVG in HTML
  • Geolocation API
  • Drag and Drop
  • Local Storage
  • Web Workers

Web Accessibility

  • Introduction to Accessibility
  • ARIA Attributes
  • Keyboard Navigation
  • Alt Text Best Practices
  • Color Contrast and Typography
  • Testing for Accessibility

Best Practices & SEO

  • HTML Best Practices
  • SEO Fundamentals
  • Meta Tags for SEO
  • Structured Data

What is Semantic HTML?

Understanding semantic markup

Semantic HTML uses HTML elements that carry meaning about the content they contain, not just how they should look. Instead of using generic containers, semantic HTML describes what the content is—whether it's a navigation menu, an article, a header, or a footer. This makes your code more meaningful to browsers, search engines, and assistive technologies.

What Does "Semantic" Mean?

The word "semantic" relates to meaning. In HTML, semantic elements clearly describe their meaning to both the browser and the developer. They tell you what type of content they contain, not just how it looks.

For example:

  • <article> tells you the content is a self-contained article
  • <nav> tells you the content is navigation links
  • <header> tells you the content is a header section
  • <footer> tells you the content is a footer section

Semantic vs. Non-Semantic Elements

Let's compare semantic and non-semantic elements:

Non-Semantic Elements

These elements don't tell you anything about their content. They're generic containers:

  • <div> - Generic block container
  • <span> - Generic inline container

Semantic Elements

These elements clearly describe their content:

  • <header> - Header section
  • <nav> - Navigation links
  • <main> - Main content
  • <article> - Self-contained content
  • <section> - Thematic grouping
  • <aside> - Sidebar or tangential content
  • <footer> - Footer section

Side-by-Side Comparison

Here's the same page structure written two different ways:

Non-Semantic Approach (Bad)

non-semantic.html
<!DOCTYPE html>
<html>
<head>
  <title>My Blog</title>
</head>
<body>
  <!-- No meaning - just generic divs -->
  <div id="header">
    <div id="logo">My Blog</div>
    <div id="menu">
      <a href="/">Home</a>
      <a href="/about">About</a>
      <a href="/contact">Contact</a>
    </div>
  </div>
  
  <div id="content">
    <div class="post">
      <div class="post-title">My First Blog Post</div>
      <div class="post-date">January 15, 2024</div>
      <div class="post-content">
        This is my first blog post...
      </div>
    </div>
  </div>
  
  <div id="sidebar">
    <div class="widget">Recent Posts</div>
    <div class="widget">Categories</div>
  </div>
  
  <div id="footer">
    <p>&copy; 2024 My Blog</p>
  </div>
</body>
</html>

Semantic Approach (Good)

semantic.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Blog</title>
</head>
<body>
  <!-- Clear meaning with semantic elements -->
  <header>
    <h1>My Blog</h1>
    <nav>
      <a href="/">Home</a>
      <a href="/about">About</a>
      <a href="/contact">Contact</a>
    </nav>
  </header>
  
  <main>
    <article>
      <h2>My First Blog Post</h2>
      <time datetime="2024-01-15">January 15, 2024</time>
      <p>This is my first blog post...</p>
    </article>
  </main>
  
  <aside>
    <section>
      <h3>Recent Posts</h3>
      <!-- list of posts -->
    </section>
    <section>
      <h3>Categories</h3>
      <!-- list of categories -->
    </section>
  </aside>
  
  <footer>
    <p>&copy; 2024 My Blog</p>
  </footer>
</body>
</html>

Why Semantic HTML Matters

Using semantic HTML isn't just about following best practices—it provides real, tangible benefits:

1. Accessibility

Screen readers and other assistive technologies rely on semantic HTML to help users navigate web pages. When you use semantic elements, these tools can:

  • Identify the main content area with <main>
  • Skip to navigation with <nav>
  • Jump between articles with <article>
  • Understand the page structure and relationships between content
accessibility-example.html
<!-- Screen readers can identify and announce: -->
<!-- "Navigation region" -->
<nav>
  <a href="/">Home</a>
  <a href="/products">Products</a>
</nav>

<!-- "Main content" -->
<main>
  <h1>Welcome to Our Store</h1>
  <!-- content -->
</main>

<!-- "Article" -->
<article>
  <h2>Product Review</h2>
  <!-- article content -->
</article>

2. Search Engine Optimization (SEO)

Search engines use semantic HTML to better understand your page content and structure. This can improve your rankings because:

  • Search engines can identify the main content with <main>
  • They understand what's navigation vs. content
  • They can distinguish articles from sidebars
  • They recognize the importance hierarchy of your content
seo-example.html
<!-- Search engines understand this structure -->
<main>
  <article>
    <h1>Ultimate Guide to Web Development</h1>
    <p>This comprehensive guide covers...</p>
    
    <section>
      <h2>Getting Started</h2>
      <p>First, you need to...</p>
    </section>
    
    <section>
      <h2>Advanced Topics</h2>
      <p>Once you master the basics...</p>
    </section>
  </article>
</main>

<aside>
  <h3>Related Articles</h3>
  <!-- sidebar content -->
</aside>

3. Code Readability and Maintainability

Semantic HTML makes your code easier to read and maintain. Other developers (or future you) can quickly understand the page structure:

readability-comparison.html
<!-- Hard to understand -->
<div class="top-section">
  <div class="logo-area">...</div>
  <div class="links-container">...</div>
</div>

<!-- Immediately clear -->
<header>
  <div class="logo">...</div>
  <nav>...</nav>
</header>

4. Future-Proofing

Semantic HTML is part of web standards. Browsers and tools will continue to improve their support and features for semantic elements, making your site more compatible with future technologies.

Common Semantic Elements

Here's a quick overview of the most important semantic elements you'll use:

Structural Elements

structural-elements.html
<!-- Page header -->
<header>
  <h1>Site Title</h1>
  <nav>Navigation</nav>
</header>

<!-- Main content (only one per page) -->
<main>
  <h1>Page Title</h1>
  <!-- primary content -->
</main>

<!-- Page footer -->
<footer>
  <p>&copy; 2024 Company Name</p>
</footer>

Content Elements

content-elements.html
<!-- Self-contained content -->
<article>
  <h2>Article Title</h2>
  <p>Article content...</p>
</article>

<!-- Thematic grouping -->
<section>
  <h2>Section Title</h2>
  <p>Section content...</p>
</section>

<!-- Tangential content -->
<aside>
  <h3>Related Information</h3>
  <p>Sidebar content...</p>
</aside>

<!-- Navigation links -->
<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/about">About</a></li>
  </ul>
</nav>

Practical Example: Blog Post Page

Here's a complete example of a semantic blog post page:

blog-post-semantic.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Understanding JavaScript Closures | Tech Blog</title>
</head>
<body>
  <!-- Site header -->
  <header>
    <h1>Tech Blog</h1>
    <nav>
      <ul>
        <li><a href="/">Home</a></li>
        <li><a href="/articles">Articles</a></li>
        <li><a href="/about">About</a></li>
        <li><a href="/contact">Contact</a></li>
      </ul>
    </nav>
  </header>
  
  <!-- Main content area -->
  <main>
    <!-- Blog post article -->
    <article>
      <header>
        <h2>Understanding JavaScript Closures</h2>
        <p>
          Published on <time datetime="2024-01-15">January 15, 2024</time>
          by <span>John Doe</span>
        </p>
      </header>
      
      <section>
        <h3>What is a Closure?</h3>
        <p>
          A closure is a function that has access to variables from
          another function's scope...
        </p>
      </section>
      
      <section>
        <h3>How Closures Work</h3>
        <p>
          When you create a function inside another function...
        </p>
      </section>
      
      <section>
        <h3>Practical Examples</h3>
        <p>
          Let's look at some real-world examples...
        </p>
      </section>
      
      <footer>
        <p>Tags: <a href="/tag/javascript">JavaScript</a>, <a href="/tag/programming">Programming</a></p>
      </footer>
    </article>
    
    <!-- Comments section -->
    <section>
      <h3>Comments</h3>
      
      <article>
        <header>
          <h4>Jane Smith</h4>
          <time datetime="2024-01-16">January 16, 2024</time>
        </header>
        <p>Great explanation! This really helped me understand closures.</p>
      </article>
      
      <article>
        <header>
          <h4>Bob Johnson</h4>
          <time datetime="2024-01-17">January 17, 2024</time>
        </header>
        <p>Thanks for sharing. Do you have more examples?</p>
      </article>
    </section>
  </main>
  
  <!-- Sidebar -->
  <aside>
    <section>
      <h3>Recent Posts</h3>
      <ul>
        <li><a href="/post/arrays">Working with Arrays</a></li>
        <li><a href="/post/promises">Understanding Promises</a></li>
        <li><a href="/post/async">Async/Await Explained</a></li>
      </ul>
    </section>
    
    <section>
      <h3>Categories</h3>
      <ul>
        <li><a href="/category/javascript">JavaScript</a></li>
        <li><a href="/category/css">CSS</a></li>
        <li><a href="/category/html">HTML</a></li>
      </ul>
    </section>
  </aside>
  
  <!-- Site footer -->
  <footer>
    <p>&copy; 2024 Tech Blog. All rights reserved.</p>
    <nav>
      <a href="/privacy">Privacy Policy</a>
      <a href="/terms">Terms of Service</a>
      <a href="/contact">Contact Us</a>
    </nav>
  </footer>
</body>
</html>

When to Still Use div

While semantic elements are preferable, <div> still has its place:

  • For styling purposes (wrappers, containers)
  • When no semantic element fits
  • For layout structures without semantic meaning
appropriate-div-use.html
<article>
  <h2>Article Title</h2>
  
  <!-- div for styling/layout -->
  <div class="image-gallery">
    <img src="photo1.jpg" alt="Photo 1">
    <img src="photo2.jpg" alt="Photo 2">
  </div>
  
  <!-- div for grid layout -->
  <div class="content-grid">
    <p>First paragraph...</p>
    <p>Second paragraph...</p>
  </div>
</article>

Common Mistakes to Avoid

1. Using Multiple main Elements

multiple-main-mistake.html
<!-- Wrong: Only one <main> per page -->
<main>
  <h1>First Section</h1>
</main>
<main>
  <h1>Second Section</h1>
</main>

<!-- Correct: One <main> with multiple sections -->
<main>
  <section>
    <h1>First Section</h1>
  </section>
  <section>
    <h1>Second Section</h1>
  </section>
</main>

2. Nesting nav Inside nav

nested-nav-mistake.html
<!-- Wrong: Don't nest nav elements -->
<nav>
  <nav>
    <a href="/">Home</a>
  </nav>
</nav>

<!-- Correct: Use one nav with nested lists if needed -->
<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li>
      <a href="/products">Products</a>
      <ul>
        <li><a href="/products/software">Software</a></li>
        <li><a href="/products/hardware">Hardware</a></li>
      </ul>
    </li>
  </ul>
</nav>

3. Using article for Everything

article-misuse.html
<!-- Wrong: article should be self-contained and reusable -->
<article>
  <h1>Page Title</h1>
  <article>Some text</article>
  <article>More text</article>
</article>

<!-- Correct: Use article only for self-contained content -->
<article>
  <h2>Blog Post Title</h2>
  <p>Blog post content that makes sense on its own...</p>
</article>

Best Practices

1. Always Choose Semantic First

Ask yourself: "Is there a semantic element that describes this content?"

semantic-first.html
<!-- Instead of div with class... -->
<div class="navigation">
  <a href="/">Home</a>
</div>

<!-- Use the semantic element -->
<nav>
  <a href="/">Home</a>
</nav>

2. Use Headings Correctly

Maintain proper heading hierarchy with semantic elements:

heading-hierarchy.html
<main>
  <h1>Page Title</h1>
  
  <article>
    <h2>Article Title</h2>
    
    <section>
      <h3>Section Title</h3>
      <p>Content...</p>
    </section>
    
    <section>
      <h3>Another Section</h3>
      <p>Content...</p>
    </section>
  </article>
</main>

3. Test Your Structure

Use browser developer tools to inspect your document outline and ensure it makes sense.

Key Takeaways

  • Semantic HTML uses elements that describe their content's meaning
  • Improves accessibility for screen readers and assistive technologies
  • Helps search engines understand and rank your content
  • Makes code more readable and maintainable
  • Use semantic elements like <header>, <nav>, <main>, <article>, <section>, <aside>, and <footer>
  • Choose semantic elements over generic <div> when appropriate
  • Only use one <main> element per page
  • Test your document structure with developer tools

What's Next?

Now that you understand what semantic HTML is and why it matters, the next lessons will dive deeper into specific semantic elements. We'll start with the <header> and <footer> elements, learning how to use them effectively in your web pages.

Know someone who'd find this guide helpful? Please share!

Previous
Form Accessibility
Next
Header and Footer

Never Miss a New HTML Tutorial

Join 1,000+ developers learning HTML step-by-step. Get new tutorials, tips, and exclusive resources delivered to your inbox - completely FREE.

You might also like

UI Components

Ready-made components for your projects

Developer Tools

Boost productivity with handy generators

HTML Game

Learn HTML concepts through interactive gameplay

Join Our Web Development Training Program

Master frontend & backend development with hands-on projects.

Menu

Topics

Getting Started

  • What is HTML?
  • How the Web Works
  • Setting Up Your Environment
  • Your First HTML Page

HTML Document Structure

  • The DOCTYPE Declaration
  • The HTML Element
  • The Head Section
  • Meta Tags
  • The Body Element
  • HTML Comments

Text and Formatting

  • Headings (h1-h6)
  • Paragraphs
  • Line Breaks and Horizontal Rules
  • Text Formatting (Bold, Italic, etc.)
  • Quotations and Citations
  • Preformatted Text and Code
  • Subscript and Superscript

Links and Navigation

  • Creating Links
  • Absolute vs Relative URLs
  • Link Targets and Attributes
  • Email and Phone Links
  • Internal Page Links

Images and Media

  • Adding Images
  • Image Attributes
  • Image Formats
  • Figure and Figcaption
  • Responsive Images
  • Audio Elements
  • Video Elements
  • Embedding Content

Lists

  • Unordered Lists
  • Ordered Lists
  • Description Lists
  • Nested Lists

Tables

  • Table Basics
  • Table Headers and Footers
  • Spanning Columns and Rows
  • Table Captions
  • Styling Tables

Forms - Part 1 (Basics)

  • Introduction to Forms
  • Text Input Fields
  • Labels and Placeholders
  • Textarea Element
  • Checkboxes
  • Radio Buttons

Forms - Part 2 (Advanced)

  • Select Dropdowns
  • File Upload Inputs
  • HTML5 Input Types
  • Form Validation
  • Form Buttons
  • Fieldsets and Legends
  • Form Accessibility

Semantic HTML

  • What is Semantic HTML?
  • Header and Footer
  • Nav Element
  • Main and Article
  • Section and Aside
  • Div vs Semantic Elements
  • Time and Mark Elements

HTML5 Features

  • HTML5 Overview
  • Canvas Element
  • SVG in HTML
  • Geolocation API
  • Drag and Drop
  • Local Storage
  • Web Workers

Web Accessibility

  • Introduction to Accessibility
  • ARIA Attributes
  • Keyboard Navigation
  • Alt Text Best Practices
  • Color Contrast and Typography
  • Testing for Accessibility

Best Practices & SEO

  • HTML Best Practices
  • SEO Fundamentals
  • Meta Tags for SEO
  • Structured Data
Falytom logoFALYTOM

Learn technologies like HTML, CSS, JavaScript, React, NodeJS and more through interactive games, tutorials, components and free tools. Transform your businesses with AI chatbots, SEO-optimized websites, and professional development services.

© 2025 Tomilola Group
  • Facebook logo
  • Twitter logo
  • Instagram logo
  • LinkedIn logo
  • GitHub logo
  • YouTube logo