What is semantic HTML?
Semantic HTML means using tags that clearly describe the meaning and purpose of your content. Instead of wrapping everything in generic <div> elements, you use tags like <article>, <header>, <nav>, and <section> that tell the browser (and humans) exactly what that content is.
Compare these two:
- Non-semantic:
<div class="header"><div class="nav">...</div></div>โ A browser sees generic divs with classes. - Semantic:
<header><nav>...</nav></header>โ A browser knows this is the page header and navigation.
Semantic HTML matters for three reasons:
- Accessibility: Screen readers understand structure and can navigate your page better.
- SEO: Search engines use semantic tags to understand what your page is really about.
- Maintainability: Your code is clearer and easier to understand โ for you and your team.
Page-level structure tags
These tags define the major regions of your page. Every HTML page typically uses all four:
<header>โ The top section. Usually contains logo, title, or introductory content.<nav>โ Navigation links. Use this to mark up menus and link collections.<main>โ The main content area. There should be only ONE<main>per page.<footer>โ The bottom section. Usually contains copyright, links, contact info.
Notice how readable this is โ even without seeing the page, you understand the structure. A screen reader would announce: "You are in the header, then the navigation, then the main content, then the footer."
Content grouping: article, section, aside
Inside <main>, use these tags to organize content:
<article>โ A standalone piece of content: a blog post, news story, product review, or comment. You can have multiple articles on one page.<section>โ A thematic grouping of content. Use it to group related content together. Usually has a heading.<aside>โ Content related to the main content but separate: a sidebar, related links, or additional info.
This structure makes it clear what's the main article, what are its sections, and what's supplementary.
Expandable content: details and summary
The <details> and <summary> tags create accordion-style expandable sections without any JavaScript. Perfect for FAQs and collapsible content.
Click the summary to expand or collapse the details. No JavaScript needed! The browser handles it all.
Try it yourself: Build a semantic page layout
Edit the code below to create a complete semantic HTML page. Notice how the page reads clearly even without CSS โ the structure is meaningful.
Inline semantic tags: time, address, mark
Beyond the big structural tags, HTML has inline tags that add meaning to specific content:
<time>โ Marks dates and times. Thedatetimeattribute provides a machine-readable format.<address>โ Contact information. Search engines use this to find contact details.<mark>โ Highlights text that's relevant to the user (like search results).<strong>โ Important text (stronger emphasis than<b>).<em>โ Emphasized text (like italics, but with semantic meaning).
The datetime attribute on <time> lets search engines and assistants understand the exact date, even if you display it differently.
Div soup vs semantic HTML
Here's a real comparison: the same layout written two ways. Which is easier to understand?
โ Div soup version:
โ Semantic HTML version:
The semantic version is shorter, clearer, and more meaningful. A screen reader knows exactly what each section is. A search engine understands the content hierarchy. Your future self (or a teammate) immediately grasps the structure.
Try it yourself: Expandable FAQ with details/summary
Build an interactive FAQ using <details> and <summary>. No JavaScript needed!
Task: You're given a page built with divs and classes. Rewrite it using semantic HTML tags (<header>, <nav>, <main>, <article>, <aside>, <footer>) instead.
The "old" div-soup HTML:
<div class="top-section">
<h1>News Site</h1>
</div>
<div class="menu">
<a href="/">Home</a> | <a href="/news">News</a>
</div>
<div class="main-section">
<div class="news-item">
<h2>Breaking News</h2>
<p>Something important happened...</p>
</div>
</div>
<div class="bottom">
<p>© 2026 News</p>
</div>
</div>
Your task: Rewrite this using semantic tags. What replaces <div class="top-section">? What about <div class="menu">? Start with the template from the editors above and modify it.
Hint: Replace div class="top-section" with <header>, div class="menu" with <nav>, div class="main-section" with <main>, div class="news-item" with <article>, and div class="bottom" with <footer>. Remove the container div entirely โ it's not needed!
Key takeaways
- Semantic HTML uses tags that describe meaning:
<header>,<nav>,<main>,<article>,<section>,<aside>,<footer>. - Semantic HTML improves accessibility (screen readers), SEO (search engines), and maintainability (your code is clearer).
- Use
<details>and<summary>for expandable content โ no JavaScript needed. - Inline semantic tags like
<time>,<address>,<mark>add meaning to specific content. - Always prefer semantic tags over generic
<div>with classes โ your future self will thank you.
Test your knowledge
You just mastered semantic HTML.
Ready to build real websites?
Join the Best AI Programs โ three 5-month courses, fully online, with placement assistance. Week 1 is free.
Explore our AI-era courses โ