What is Semantics?
In HTML, a Semantic element clearly describes its meaning to both the browser and the developer. Using
<div> for everything is "Non-semantic" because a div tells you nothing about its content.Why use Semantic HTML?
- SEO: Search engines (like Google) can understand your page much better.
- Accessibility: Screen readers for blind users rely on these tags to navigate the page.
- Maintainability: Your code is much easier to read and organize.
Core Semantic Tags
| Tag | Purpose |
|---|---|
<header> | Introduction or navigation links |
<nav> | A block of navigation links |
<main> | The unique, central content of the page |
<section> | A standalone section of a document |
<article> | A self-contained piece of content (like a blog post) |
<aside> | Content related to the main, but not essential (sidebar) |
<footer> | Information about the author, copyright, or contact info |
The "Div" Habit
Wait! It's easy to fall into the habit of using
<div> for everything. A div is just a "container" with no meaning. Only use a <div> when there is no semantic tag that fits.Summary
| Term | Description |
|---|---|
| Semantic | Meaningful tag names |
| SEO | Search Engine Optimization |
| A11y | Short for Accessibility |
| Section | A thematic grouping of content |
| Article | Independent, reusable content |
| Best For | Building high-quality, accessible, and searchable websites |
| Logic | "Describe WHAT the content is, not just HOW it looks" |
| Safety | Semantic HTML is the foundation of a bug-free web |
| Modern | Search engines prioritize sites with good semantic structure |
| Standard | Part of the HTML5 specification |
| Identity | The difference between a "Junior" and a "Senior" developer |