Semantic HTML Tags
Give meaning to your structure — don't just use divs
Skills taught: html.semantic-tags, html.accessibility-basics
Semantic HTML is the practice of using elements whose names describe their content's role. The alternative — wrapping everything in generic <div> elements — creates pages that look the same visually but mean nothing to machines.
The div problem
Here is the same page layout written two ways. Both look identical in a browser. But they mean very different things:
<div id="header">
<div class="nav">
<div class="nav-item"><a href="/">Home</a></div>
<div class="nav-item"><a href="/about">About</a></div>
</div>
</div>
<div id="main">
<div class="article">
<div class="article-title">My Post</div>
<div class="article-content">...</div>
</div>
</div>
<div id="footer">© 2026</div>
<header>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
</header>
<main>
<article>
<h1>My Post</h1>
<p>...</p>
</article>
</main>
<footer>© 2026</footer>
Key semantic elements
<header> — introductory content (logo, navigation, site title)<nav> — a set of navigation links<main> — the primary content of the page (only one per page)<article> — self-contained, independently distributable content (blog post, news story)<section> — a thematic grouping of content with a heading<aside> — tangentially related content (sidebar, callout box)<footer> — closing info (copyright, links, contact)<figure> / <figcaption> — an image or diagram with its caption<time> — a date or time value<address> — contact information
A realistic page layout
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>KERNAL Blog</title>
</head>
<body>
<header>
<nav aria-label="Main navigation">
<a href="/">Home</a>
<a href="/learn">Learn</a>
<a href="/about">About</a>
</nav>
</header>
<main>
<article>
<header>
<h1>Introduction to HTML</h1>
<time datetime="2026-09-20">September 20, 2026</time>
</header>
<section>
<h2>What is HTML?</h2>
<p>HTML stands for HyperText Markup Language...</p>
</section>
<section>
<h2>Your first page</h2>
<p>Start with this boilerplate...</p>
</section>
</article>
<aside>
<h2>Related lessons</h2>
<ul>
<li><a href="/learn/html/css-basics">CSS Basics</a></li>
</ul>
</aside>
</main>
<footer>
<p>© 2026 KERNAL. MIT License.</p>
</footer>
</body>
</html>
<article> can contain its own <header> and <footer>. Semantic elements can be nested — a page header and an article header are both valid uses of <header>.
Why this matters: three reasons
- Accessibility. Screen readers announce landmark roles. When a user presses a key to jump to main content, they jump to <main>. This only works with semantic HTML.
- SEO. Search engines use semantic structure to understand your page. <article> signals independent content. <nav> tells Google where the navigation is.
- Maintainability.
<nav> is more readable than <div class="navigation-wrapper">. Your future self will thank you.
Common misconception: Using <div> is fine as long as I add the right CSS class names. — Reality: CSS class names are invisible to screen readers, search engines, and browsers. Only HTML elements carry semantic meaning. <nav class='nav'> is not the same as <nav> — the class adds nothing the element doesn't already provide.
Frequently Asked Questions
When should I use <section> vs <article>?
Use <article> when the content makes sense on its own — if you copy-paste it to another page, it still has meaning. Use <section> to group related content within a larger context. A blog post is an <article>. The comments section at the bottom is a <section>.
Can I still use <div>?
Yes. <div> is the right choice when you need a container for layout or styling purposes and no semantic element fits. The rule is: use the most specific semantic element available; fall back to <div> only when nothing else is appropriate.
Does semantic HTML change how the page looks?
No. Semantic elements have no built-in visual styling (except some like <h1>-<h6> and <strong>). Visually, a page of <div>s and a page of semantic elements look identical. The difference is in meaning, not appearance.