9 / 10 · Intro
Semantic page structure
Most pages share the same rough shape: a header, a menu, the main content and a footer. HTML has an element for each, and screen readers let users jump straight to them.
Jump to the 10 practice questions1Explain
From div soup to landmarks
For years, pages were built from <div> elements with class names such as header or menu. A <div> is a generic box with no meaning at all, so the class name was the only clue, and only people reading the code could see it. HTML now has elements that say what each region is. Browsers, search engines and assistive technology understand them.
A common page shape. Only the labels are standard; the positions come from CSS and can change on a phone.
2Explain
The main regions
These elements describe meaning, not position. A <nav> does not have to sit at the top, and an <aside> does not have to be on the right; on a phone the aside usually ends up below the main content. Positions come from CSS. Choose the element by asking what the content is, the same way you chose heading levels by structure rather than size.
The preview looks plain: these elements change the meaning, not the look. CSS decides where each region sits.
<header>
<h1>Corner Bakery</h1>
<nav><a href="#bread">Bread</a> · <a href="#visit">Visit</a></nav>
</header>
<main>
<article><h2>New rye loaf</h2><p>Baked every morning.</p></article>
</main>
<aside><p>Open daily from 7 am.</p></aside>
<footer><p>12 Mill Street</p></footer>3Problem
How many main?
How many visible main elements should a page have?
Hint
main holds the one main content of the page.
Solution
Answer: 1
One main holds the content unique to the page.
4Problem
The site menu
Hint
Short for navigation.
Solution
Answer: nav
nav marks major navigation.
5Problem
A post that stands alone
The question to ask is whether the piece would make sense on its own somewhere else, for example in a news reader or shared as a link. If yes, it is an <article>. If it only makes sense as part of something larger, like the Ingredients part of a recipe, it is a <section>. Both should normally start with a heading. Articles can contain sections, and a section can contain articles, such as a Latest posts section holding several post cards.
A blog post that could be shared on its own is
Hint
Would it make sense shared on its own?
Solution
Answer: article
article is for self-contained pieces.
6Problem
Ingredients inside a recipe
The Ingredients part of a recipe article is
Hint
It is a part of a bigger piece, not a piece on its own.
Solution
Answer: section
It only makes sense inside the recipe, so it is a section.
7Explore
Same box, different meaning
The preview barely changes. What changes is what the box tells screen readers and search engines: a piece that stands alone, a part of something bigger, a side note, or nothing at all.
Tap a choice: the code and the preview change together.
<article>
<h2>Rye week</h2>
<p>A different rye loaf every day.</p>
</article>Nothing is drawn: there is no visible content.
8Explain
div and span still have a place
When no element fits, use <div> for a block and <span> for a few words inside a line. They are useful as hooks for CSS, for example a <div class="cards"> that arranges cards in a grid. The rule is to reach for a meaningful element first and fall back to a generic one only when nothing describes the content. A page made only of divs works, but it hides its structure from everyone who does not look at the code.
<p>Today: <span style="background:#1466b8;color:#fff;padding:2px 6px">Fresh rye</span></p>
<div style="display:flex;gap:8px">
<div>Sourdough</div>
<div>Rye</div>
</div>9Problem
What a div means
What does a div mean?
Hint
It is a generic box.
Solution
Answer: Nothing; it is a generic box
div has no meaning; use it when nothing else fits.
10Problem
Regions with a meaning
<header>…</header>
<nav>…</nav>
<main>…</main>
<div class="banner">…</div>
<aside>…</aside>
<footer>…</footer>How many of these elements give a page region a meaning?
Hint
One of them is a generic box.
Solution
Answer: 5
header, nav, main, aside and footer each say what their region is: 5. The div with class="banner" means nothing by itself; the class only helps CSS.
11Problem
More than one header
Can a page have a header for the site and another header inside an article?
Hint
main is the element limited to one per page.
Solution
Answer: Yes: an article can have its own header
header introduces the part it sits in, so each article can open with its own header, for example its title and date.
12Problem
Address and copyright
The address of the shop and the copyright line sit at the bottom of every page. Which element holds them?
Hint
It is the closing region of the page.
Solution
Answer: footer
footer holds information about the page or site, such as contact details and copyright. aside is for side notes, nav for menus.
13Practice
Replace the divs
Replace the divs with semantic elements: header, nav, main, article, aside and footer.
- header with h1
- nav with 3 links
- article inside main
- aside
- footer
<div class="header">
<h1>Corner Bakery</h1>
<div class="menu">
<a href="#bread">Bread</a>
<a href="#cakes">Cakes</a>
<a href="#visit">Visit</a>
</div>
</div>
<div class="content">
<div class="post">
<h2>New rye loaf</h2>
<p>From Monday we bake a dark rye every morning.</p>
</div>
</div>
<div class="sidebar">
<p>Open daily from 7 am.</p>
</div>
<div class="bottom">
<p>12 Mill Street</p>
</div>Hint
header→header, menu→nav, content→main, post→article, sidebar→aside, bottom→footer.
A solution
<header>
<h1>Corner Bakery</h1>
<nav>
<a href="#bread">Bread</a>
<a href="#cakes">Cakes</a>
<a href="#visit">Visit</a>
</nav>
</header>
<main>
<article>
<h2>New rye loaf</h2>
<p>From Monday we bake a dark rye every morning.</p>
</article>
</main>
<aside>
<p>Open daily from 7 am.</p>
</aside>
<footer>
<p>12 Mill Street</p>
</footer>14Explain
Common mistakes
You may meet the role attribute, part of a W3C standard called WAI-ARIA, written as <div role="navigation">. It gives a generic element a meaning for assistive technology. The W3C guidance on using ARIA starts with a simple rule: if a native HTML element already has the meaning you need, use it instead. <nav> is shorter, works everywhere and cannot be forgotten in one place and remembered in another.
<div role="navigation">
<a href="#bread">Bread</a>
</div><nav>
<a href="#bread">Bread</a>
</nav>When a native element exists, use it: nav already means navigation, with no role needed.
15
Summary
- header, nav, main, article, section, aside and footer name the regions of a page.
- Choose by meaning; CSS decides position.
- Use div and span only when no meaningful element fits.