Lesson 8 of 29 · Page Structure & Forms
Semantic HTML: header, nav, main, section, article and footer
So far your pages have been a column of headings, paragraphs and images. Real websites have regions: a header with the logo and menu, the main content, a footer at the bottom. HTML has an element for each of them, and using the right one makes your page easier to use for people, search engines and other developers.
<div>: a box without meaning
<div> is a generic container. It groups elements so you can style or position them together, but it says nothing about what's inside. Many older sites are built from nothing but <div> elements — developers call it "div soup":
<div class="header">
<div class="nav">...</div>
</div>
<div class="main">...</div>
The class names help the developer, but browsers and screen readers can't understand them. (You'll use classes for styling in the CSS chapter.)
The semantic elements
Semantic elements look exactly like a <div> by default — but their names say what they contain:
<header>— the introduction of the page: logo, site name, often the main navigation.<nav>— a block of major navigation links.<main>— the main content of the page. Use exactly one, and never put it inside<header>or<footer>.<section>— a themed group of content, almost always with its own heading.<article>— a self-contained piece that makes sense on its own: a blog post, a news story, a product card, a comment.<footer>— the end of the page: copyright, contact details, related links.
Put together, a typical page looks like this:
<body>
<header>
<h1>Dragon Weekly</h1>
<nav>
<a href="/">Home</a>
<a href="/news">News</a>
</nav>
</header>
<main>
<section>
<h2>Latest news</h2>
<article>
<h3>Dragon spotted over the cliffs</h3>
<p>A red dragon circled the lighthouse twice.</p>
</article>
</section>
</main>
<footer>
<p>© 2026 Dragon Weekly</p>
</footer>
</body>
© is a character reference: a code the browser turns into the © sign.
Why semantics matter
- Accessibility. Screen readers turn these elements into landmarks. A blind visitor can jump straight to the
<main>content or to the<nav>, instead of listening to the whole page from the top. - SEO. Search engines can tell your real content apart from menus and footers, and an
<article>signals a standalone piece worth showing in results. - Readable code.
</main>tells you exactly what just ended. The seventh</div>in a row doesn't.
Section or article?
Ask yourself: "Would this still make sense on its own — shared on social media or in a news feed?" If yes, it's an <article>. If it's one part of a bigger whole, like the "Latest news" area of a homepage, it's a <section>. And if you only need a wrapper for styling, a plain <div> is still the right tool.
Common mistakes
- Mixing up
<header>,<head>and headings.<head>holds information about the page, like the<title>;<header>is a visible region of the page;<h1>to<h6>are headings. - More than one
<main>, or a<main>inside the header or footer. - A
<section>without a heading, used only to wrap things — that's a job for<div>. - Wrapping every link in
<nav>. It's for major navigation blocks, not for each link in the text.
Assignment
The news page below is pure div soup. Replace every <div> with the semantic element its class names — and change the matching </div> as well. You can drop the class attributes.
header→<header>(it holds the<h1>and the navigation)nav→<nav>main→<main>section→<section>- both
articleboxes →<article> footer→<footer>
When you're done, the page must not contain a single <div>. The Preview won't change: semantic elements look like plain boxes until you style them — the difference is in the meaning.
Premium lesson
Unlock the full Learn HTML & CSS course
- All 29 lessons, bosses and quizzes — lifetime access
- One payment of $35, no subscription
- Finish within 30 days and claim $10.50 (30%) back
Want more than one course?
The All-Access Pass unlocks all 8 courses and every new one we release, for $120 once.
Keep learning
Need a quick reminder? The HTML & CSS cheat sheet has every topic of Learn HTML & CSS on one page.
Lesson last updated on .