HTML Semantic Tags
Learn semantic HTML tags that describe content meaning for accessibility and SEO.
What you'll learn
- What semantic HTML is and why it matters
- The key semantic tags: header, nav, main, article, section, aside, footer
- How semantics improve accessibility for screen readers
- How semantic markup boosts search engine understanding
Concept
HTML Semantic Tags
Semantic HTML means using tags that describe the *meaning* of their content, not just how it looks. A <div> tells you nothing — it is a generic container. But <article> says "this is a self-contained piece of content," and <nav> says "this is navigation." Semantic tags give your markup meaning that browsers, screen readers, and search engines can act on.
The Core Semantic Tags
<header>— introductory content or a group of navigation links, typically at the top of a page or section.<nav>— a section of navigation links. Not every group of links is<nav>— reserve it for major navigation blocks.<main>— the dominant content of the page. There should be exactly one<main>per page.<article>— a self-contained composition: a blog post, a news story, a product card. It makes sense on its own.<section>— a thematic grouping of content, usually with a heading. Use it to divide a page into chapters.<aside>— content tangentially related to the main content, like a sidebar or a pull quote.<footer>— closing content: copyright, contact info, related links.
Why Semantics Matter
Screen readers use semantic tags to navigate. A user can jump straight to the <nav> or skip to <main> content. Without semantics, the page is an undifferentiated sea of <div>s, and assistive technology cannot help the user move efficiently. Search engines also use semantic structure to understand what your page is about, which can improve rankings.
Divs vs. Semantic Tags
You will still use <div> — it is the right choice when no semantic tag fits. The rule is simple: use a semantic tag when one exists, fall back to <div> only when it does not. Replacing every <div> with a semantic tag is not the goal; using the *right* tag for the *right* content is.
Example
<!DOCTYPE html>
<html lang="en">
<body>
<header>
<h1>My Blog</h1>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/archive">Archive</a>
</nav>
</header>
<main>
<article>
<h2>Why Semantic HTML Matters</h2>
<p>Semantic tags describe content meaning.</p>
<section>
<h3>Accessibility</h3>
<p>Screen readers navigate by landmarks.</p>
</section>
</article>
<aside>
<h3>Related Posts</h3>
<ul><li>HTML Forms 101</li><li>CSS Selectors</li></ul>
</aside>
</main>
<footer>© 2024 My Blog</footer>
</body>
</html>
Each tag describes its role: header for the top banner, nav for links, main for the primary content, article for a post, section for a sub-topic, aside for related content, and footer for closing info.
Try it
- HTML ↔ Markdown
See how semantic HTML structure maps to Markdown headings and sections.
- HTML Entity Encoder
Encode special characters in your semantic HTML content safely.
Common mistakes
The mistake
Using <div> for everything instead of semantic tags.
The fix
Use <header>, <nav>, <main>, <article>, <section>, <aside>, <footer> where they fit. Reserve <div> for when no semantic tag applies.
The mistake
Having more than one <main> element per page.
The fix
There must be exactly one <main> per page. It wraps the dominant content. Sidebars and headers live outside it.
Related Resources
Related Cheatsheets
- HTML Cheatsheet
Full reference for all semantic and structural HTML tags.
Practice HTML Semantic Tags
6 exercises
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.