What's Wrong With a Page Full of divs
Open the browser developer tools and inspect the HTML of many websites — you'll find structures like this:
<div class="header">
<div class="nav">
<div class="nav-item">Home</div>
</div>
</div>
<div class="main">
<div class="article">
<div class="title">Article Title</div>
<div class="content">Body content...</div>
</div>
</div>
<div class="footer">Copyright info</div>
Visually, this looks fine — the browser renders it without complaint. But for search engine crawlers and screen readers, it's a meaningless pile of boxes. They have no way to tell which part is navigation, which is the main content, and which is the footer.
Semantic HTML exists to solve exactly this problem.
What Semantic HTML Actually Means
Semantic HTML means using elements that express the meaning of content, rather than using div and span as pure layout containers for everything.
HTML5 introduced a rich set of semantic elements that let the tag itself communicate what a block of content is — to browsers, search engines, and assistive technologies alike.
Three direct benefits:
1. SEO: Search engines can more accurately understand page structure, determine content importance and relevance, and factor this into rankings.
2. Accessibility: Screen readers rely on semantic elements to help visually impaired users navigate. <nav> lets them jump straight to navigation; <main> lets them skip directly to the core content.
3. Maintainability: Seeing <article> immediately tells you this is a standalone piece of content — far clearer than encountering the 47th <div class="box"> in a file.
Core Semantic Elements Explained
<header>: Page or Section Header
Represents the introductory area of a page or a content block — typically contains a logo, site title, or primary navigation.
<header>
<img src="logo.png" alt="Site Logo">
<h1>Site Name</h1>
<nav>...</nav>
</header>
Note: <header> is not limited to the top of the page. An <article> or <section> can each have their own <header>.
<nav>: Navigation
Dedicated to navigation link groups — primary menus, breadcrumbs, and pagination are all good candidates.
<nav aria-label="Primary navigation">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/blog">Blog</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
Not every group of links belongs in <nav> — only collections of links that serve a primary navigation purpose.
<main>: Main Content
The core content area of the page. Each page should have exactly one <main>, and it must not be nested inside <header>, <footer>, <nav>, or <aside>.
<body>
<header>...</header>
<nav>...</nav>
<main>
<!-- Core page content goes here -->
</main>
<footer>...</footer>
</body>
Screen reader users can jump directly to <main> via keyboard shortcut, bypassing repeated navigation and headers.
<article>: Self-Contained Content
Represents a self-contained, independently distributable piece of content — blog posts, news items, forum threads, and comments all qualify.
The test: would this content still make sense if lifted out of the page and placed somewhere else on its own? If yes, use <article>.
<main>
<article>
<header>
<h2>Article Title</h2>
<time datetime="2024-04-06">April 6, 2024</time>
</header>
<p>Article body...</p>
<footer>
<p>By: Jane Smith</p>
</footer>
</article>
</main>
<section>: Thematic Grouping
Represents a thematic grouping within a document, usually with its own heading. The difference between <section> and <div>: a <section> has a clear theme; a <div> is just a layout container.
<article>
<section>
<h2>Background</h2>
<p>...</p>
</section>
<section>
<h2>Core Features</h2>
<p>...</p>
</section>
</article>
Common misuse: replacing every <div> with <section> is not semantic HTML. Use <section> only when the content genuinely forms a thematic group.
<aside>: Related but Non-Essential Content
Content related to the main content but not central to it — sidebars, related article lists, pull quotes, author bios, and ads.
<main>
<article>Main article content</article>
<aside>
<h3>Related Articles</h3>
<ul>
<li><a href="#">Article A</a></li>
<li><a href="#">Article B</a></li>
</ul>
</aside>
</main>
<footer>: Page or Section Footer
The bottom area of a page or content block — typically contains copyright notices, contact info, and secondary navigation.
<footer>
<p>© 2024 toolshu.com All Rights Reserved</p>
<nav aria-label="Footer navigation">
<a href="/about">About</a>
<a href="/privacy">Privacy Policy</a>
</nav>
</footer>
Like <header>, <footer> can also appear inside an <article>.
<figure> and <figcaption>: Illustrated Content
Represents a self-contained piece of content — an image, diagram, code sample — paired with an optional caption.
<figure>
<img src="architecture.png" alt="System architecture diagram">
<figcaption>Figure 1: Overall system architecture overview</figcaption>
</figure>
<time>: Dates and Times
Marks a date or time value; the datetime attribute provides the machine-readable format.
<p>Published on <time datetime="2024-04-06T10:30:00+08:00">April 6, 2024</time></p>
<address>: Contact Information
Represents contact information for the nearest <article> or <body> ancestor — not a general-purpose address tag.
<address>
Author: <a href="mailto:hello@example.com">Jane Smith</a><br>
San Francisco, CA
</address>
Semantic vs. Non-Semantic: At a Glance
| Use case | Non-semantic | Semantic |
|---|---|---|
| Page header area | <div class="header"> |
<header> |
| Navigation menu | <div class="nav"> |
<nav> |
| Main content area | <div class="main"> |
<main> |
| Blog post | <div class="post"> |
<article> |
| Content section | <div class="section"> |
<section> |
| Sidebar | <div class="sidebar"> |
<aside> |
| Page footer | <div class="footer"> |
<footer> |
| Image with caption | <div class="img-wrap"> |
<figure> + <figcaption> |
Common Misconceptions
Misconception 1: <section> is an upgraded <div>
No. Use <section> only when the content has a clear thematic grouping. Pure layout containers should still be <div>.
Misconception 2: <article> is only for written articles
Incorrect. Comments, forum posts, product cards, and widgets can all be <article> — as long as they can stand alone meaningfully.
Misconception 3: Semantic elements affect visual styling
They don't. Semantic elements have no special default styles (with a few minor exceptions like <address> being italic). CSS can style them exactly like <div> — no constraints.
Misconception 4: Using semantic tags guarantees better SEO
Semantics is one foundation of SEO, not the whole picture. Content quality, page speed, and backlinks matter just as much. But semantic HTML is the lowest-cost, most reliable baseline optimization available — there's no good reason to skip it.
Try It Directly
Finished writing a snippet of HTML and want to see it render? Paste it into the HTML Online Editor on toolshu.com — syntax highlighting, formatting, and live preview, no local setup needed.
Article URL:https://toolshu.com/en/article/html-semantic-elements
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License 。



Loading...