Estimated time: 20 minutes (about 8 minutes reading, 12 minutes practice)
Learning goals: By the end, you'll know what semantic HTML is, how to use the main layout elements, and how to build a well-structured page that people, search engines and screen readers can understand.
What is semantic HTML?
"Semantic" means "carrying meaning". A semantic element tells the browser what its content is, not just how it looks.
<!-- Non-semantic: meaning is unclear -->
<div class="top">...</div>
<!-- Semantic: meaning is clear -->
<header>...</header>Why it matters:
- Accessibility: screen reader users can jump straight to the navigation or main content.
- SEO: search engines understand your page better.
- Maintainability: code is easier to read and update.
Part 1: Page layout elements (5 min)
| Element | Purpose |
|---|---|
<header> | Introductory content: logo, title, sometimes navigation |
<nav> | A block of main navigation links |
<main> | The unique main content of the page (use one per page) |
<section> | A themed group of content, usually with a heading |
<article> | Self-contained content that makes sense alone, like a blog post |
<aside> | Related side content, like a sidebar or pull quote |
<footer> | Closing content: copyright, contact details, links |
<body>
<header>
<h1>My Travel Blog</h1>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="posts.html">Posts</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
</header>
<main>
<article>
<h2>A Weekend in Lisbon</h2>
<p>We landed on Friday morning...</p>
</article>
<aside>
<h2>About the author</h2>
<p>Hi, I'm Sam, and I love travelling.</p>
</aside>
</main>
<footer>
<p>© 2026 My Travel Blog</p>
</footer>
</body>Part 2: Section vs. article vs. div (4 min)
| Use | When |
|---|---|
<article> | Content that could be shared or republished on its own (post, news story, product card) |
<section> | A chapter or themed part of a page, normally with a heading |
<div> | A generic container with no meaning, used when no semantic element fits (for example, for styling) |
A simple test: if you can't give a <section> a heading, it probably should be a <div>.
<section>
<h2>Latest News</h2>
<article>
<h3>Site Launch</h3>
<p>We are live!</p>
</article>
<article>
<h3>New Feature</h3>
<p>Dark mode is here.</p>
</article>
</section>Part 3: More meaningful elements (4 min)
| Element | Purpose |
|---|---|
<figure> / <figcaption> | An image or diagram with a caption (Lesson 5) |
<time> | A date or time machine-readable |
<address> | Contact information for the page or article author |
<blockquote> | A longer quotation |
<abbr> | An abbreviation, with title giving the full form |
<p>Published on <time datetime="2026-10-19">19 October 2026</time></p>
<address>
Written by <a href="mailto:sam@example.com">Sam Taylor</a>
</address>
<p>Learn <abbr title="HyperText Markup Language">HTML</abbr> today.</p>Headings and structure
Headings should follow the page outline: one <h1>, then <h2> for sections, <h3> for subsections. Headers inside <article> and <section> follow the same order.
Common mistakes
-
Using
<div>for everything ("div soup") -
Having more than one
<main> -
Using
<section>as a styling wrapper with no heading -
Putting
<nav>around every group of links (use it for major navigation) - Choosing elements for how they look instead of what they mean
- Skipping heading levels
Key takeaways
- Semantic elements describe meaning, not appearance.
-
A typical page uses
<header>,<nav>,<main>,<footer>, plus<article>,<section>and<aside>inside. -
Use
<div>and<span>only when no semantic element fits. - Semantic HTML helps accessibility and SEO.
Exercises (12 min)
-
Identify (1 min). Which element suits each?
- a) The site's copyright line
- b) A blog post that could be shared alone
- c) A sidebar of related links
Answers: a)<footer>, b)<article>, c)<aside>. -
Fix the errors (3 min). Rewrite this using semantic elements:
<div class="header"> <div class="menu"> <a href="index.html">Home</a> <a href="about.html">About</a> </div> </div> <div class="content"> <div class="post"> <h1>My Post</h1> <p>Hello!</p> </div> </div> <div class="bottom">Copyright 2026</div>
Hints:header,nav(ideally with aulof links),main,article,footer. -
Build it (6 min). Create
semantic.htmlfor a recipe blog with:-
a
<header>containing the site title and a<nav>list of three links -
a
<main>containing two<article>recipes, each with a heading, an image in a<figure>and a short paragraph -
an
<aside>with a "Cooking tips" list -
a
<footer>with copyright text and an<address> -
a
<time>element showing when each recipe was posted
-
a
-
Challenge (2 min). Open your page and check the heading order. Then use your browser's developer tools (right-click, Inspect) to look at the element tree and confirm there's only one
<main>.
Lesson 9 checkpoint
- I can explain what "semantic" means.
-
I can build a page layout with
<header>,<nav>,<main>and<footer>. -
I can choose between
<article>,<section>and<div>. -
I can use
<time>,<address>and<abbr>.