Lesson 12 of 296
Semantic HTML
What you will learn
- What "semantic" means
- The page layout elements and when to use each
- Why semantic HTML matters for users, search engines and developers
- How to choose between section, article and div
On this page
What does semantic mean?
Semantic means "having meaning". A semantic element tells the browser, screen readers and search engines what the content is, not only how it looks.
Not semantic: <div class="top-menu">...</div>
Semantic: <nav>...</nav>Both can look exactly the same. But <nav> tells everyone "this is the main navigation". A <div> tells them nothing.
The layout elements
| Element | Meaning |
|---|---|
<header> | Introduction to the page or a section: logo, site name, main menu |
<nav> | A block of main navigation links |
<main> | The main content of the page. Only one visible <main> per page. |
<article> | A complete piece that makes sense on its own: a blog post, a news story, a product card, a comment |
<section> | A themed part of the page, usually with its own heading |
<aside> | Content related to the main content but not part of it: a sidebar, related links, adverts |
<footer> | Closing information: copyright, contact links, legal links |
A full page layout
<body>
<header>
<a href="/"><img src="logo.svg" alt="Acme home"></a>
<nav>
<ul>
<li><a href="/blog">Blog</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
</header>
<main>
<article>
<h1>How to plan a website</h1>
<p>Published <time datetime="2026-11-23">23 November 2026</time></p>
<section>
<h2>Step 1: Know your users</h2>
<p>...</p>
</section>
<section>
<h2>Step 2: Plan the pages</h2>
<p>...</p>
</section>
</article>
<aside>
<h2>Related posts</h2>
<ul>...</ul>
</aside>
</main>
<footer>
<p>© 2026 Acme Ltd</p>
</footer>
</body>section, article or div?
Ask these questions in order:
- Would it make sense on its own, for example if you copied it to another website or an RSS feed? Use
<article>. - Is it a themed part of the page with its own heading? Use
<section>. - Is it only for styling or layout, with no meaning? Use
<div>.
More semantic elements
| Element | Use for |
|---|---|
<time datetime="2026-11-23"> | Dates and times. datetime gives a format computers can read. |
<address> | Contact details for the page or its author |
<figure> / <figcaption> | An image, chart or code example with a caption |
<details> / <summary> | A section the user can open and close, with no JavaScript needed |
<dialog> | A pop-up box (modal) |
<abbr title="..."> | An abbreviation and its full form |
<details>
<summary>What is your refund policy?</summary>
<p>You can return any item within 30 days.</p>
</details>This makes a working question-and-answer box with plain HTML.
Why it matters
- Accessibility. Screen readers let users jump straight to
<main>, or list every<nav>. With only<div>elements, they must listen to the whole page. - Search engines. Clear structure helps Google understand which part is the main content.
- Readable code.
<footer>is easier to understand than<div class="ft-wrap-2">, for you and for your team. - Free behaviour. A
<button>can already be focused with the keyboard and pressed with Enter or Space. A<div>made to look like a button can do none of this unless you add extra code.
The button rule
This is one of the most common interview questions on HTML.
Bad: <div class="btn" onclick="save()">Save</div>
Good: <button type="button" onclick="save()">Save</button>The <div> version cannot be reached with the Tab key, does not work with Enter or Space, and a screen reader does not say it is a button. The <button> gets all of that for free.
Common mistakes
- "Div soup": a page built only from
<div>elements. - More than one visible
<main>. - Using
<section>just to wrap things for styling. If there is no heading or theme, use<div>. - Clickable
<div>or<span>elements instead of<button>or<a>.
How to say it in an interview
"Semantic HTML means using elements that describe the meaning of the content: header, nav, main, article, section, aside and footer, plus button for actions and a for navigation. It helps screen reader users navigate, helps search engines understand the page, makes the code easier to read, and gives keyboard support for free. I only use div and span when no semantic element fits."
Key words
| Word | Meaning |
|---|---|
| Semantic | Having meaning |
| Landmark | A main region such as header, nav, main or footer that assistive technology can jump to |
<main> | The main content of the page |
<article> | Content that makes sense on its own |
<section> | A themed part of a page with a heading |
| Div soup | A page built almost only from div elements |
Now prove it
This lesson is complete when you pass the quiz and all three practice levels.