Semantic HTML
non-semantic-vs-semantic.html
<!-- Non-semantic: a screen reader or search engine has no idea what this is -->
<div class="nav">
<div class="nav-item">Home</div>
<div class="nav-item">About</div>
</div>
<!-- Semantic: the purpose is explicit -->
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>Both examples can be styled identically with CSS. The difference is invisible to sighted users navigating with a mouse—but enormous for anyone using a screen reader, a search engine crawler, or a browser extension that needs to find "the navigation" programmatically.
Why "div-soup" Is a Problem
<div> and <span> elements—sometimes called "div soup"—works visually but costs you in three concrete ways.Concern | Impact of div-soup |
|---|---|
Accessibility | Screen reader users can't jump to "the main content" or "the navigation"—they have to read everything linearly |
SEO | Search engines weigh content inside <article>, <h1>-<h6>, and similar tags more heavily when judging relevance and structure |
Maintainability | A codebase of <div class="header">, <div class="header-2">, <div class="header-inner"> is far harder to scan and refactor than named, purpose-built elements |
<div> class="article" makes it easier for a human to read the source, but it tells browsers, screen readers, and search engines nothing. Only real HTML elements (or ARIA roles, as a last resort) carry machine-readable meaning.Semantic Elements Overview
Element | Represents |
|---|---|
<header> | Introductory content for a page or section |
<nav> | A block of navigation links |
<main> | The primary content of the page (one per page) |
<article> | Self-contained content that could stand alone (a post, a story) |
<section> | A thematic grouping of content, typically with its own heading |
<aside> | Content tangentially related to the surrounding content |
<footer> | Closing content for a page or section |
<figure> / <figcaption> | Self-contained media with a caption |
<time> | A date or time, optionally machine-readable |
<address> | Contact information for a person, page, or site |
A Semantic Page Skeleton
skeleton.html
<body>
<header>
<h1>My Blog</h1>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/archive">Archive</a></li>
</ul>
</nav>
</header>
<main>
<article>
<h2>Understanding Semantic HTML</h2>
<p>Semantic elements describe meaning, not appearance...</p>
</article>
<aside>
<h2>Related Posts</h2>
<ul>
<li><a href="/post-2">Why Accessibility Matters</a></li>
</ul>
</aside>
</main>
<footer>
<p>© 2026 My Blog. All rights reserved.</p>
</footer>
</body><aside>; a self-contained blog post is an <article>. Styling comes from CSS either way.<div>s for pure layout (grid wrappers, styling hooks)—that's fine. The goal is to use a semantic element wherever one accurately describes the content, and fall back to <div>/<span> for everything else.How Semantics Help Search Engines
<article> wrapping the main content, an <h1> matching the page's actual topic, and a <nav> clearly separated from body content all help a crawler decide what the page isabout versus what's boilerplate (navigation, ads, footers).seo-friendly.html
<body>
<header><!-- site branding, nav — crawlers learn to discount this --></header>
<main>
<article>
<h1>How to Brew Pour-Over Coffee</h1>
<p>Pour-over brewing gives you the most control over extraction...</p>
</article>
</main>
<footer><!-- legal links, sitemap — also discounted --></footer>
</body>How Semantics Help Assistive Technology
<header>, <nav>, <main>, <aside>, <footer>—so users can jump straight to "main content" or "navigation" instead of tabbing through everything in order. A div-soup page has no landmarks at all, forcing a purely linear listen-through-everything experience.Landmark role | Provided by |
|---|---|
banner | <header> (when it is a direct child of <body>) |
navigation | <nav> |
main | <main> |
complementary | <aside> |
contentinfo | <footer> (when it is a direct child of <body>) |
Semantic elements communicate meaning to browsers, assistive technology, and search engines—not just to human readers of the source.
Div-soup hurts accessibility (no landmarks to navigate by), SEO (less structural signal), and long-term maintainability.
CSS class names are cosmetic labels for humans; they carry no machine-readable meaning.
Reach for a semantic element whenever one accurately describes the content; use div/span for pure layout.