Semantic HTML: header, nav, main, aside and footer as Page Landmarks
The same page written as div soup and with semantic tags looks identical, but only one gives screen readers and search engines landmarks and an outline. Plus tables, div, span and the one-main rule.
What you will learn
- Replace div soup with header, nav, main, article, aside and footer
- Read the landmarks a browser builds from semantic tags
- Use a table only for real rows and columns, and div or span when no tag fits
- Keep one main element per page
Before you start
- HTML tags, elements and attributes
Nobody has to teach you how to read a newspaper. The name is at the top, a contents bar runs under it, the big story sits in the middle, a sidebar holds the extras, and the small print is at the bottom.
HTML has a name for each of those parts. The top is header, the contents bar is nav, the big story is main with an article inside, the sidebar is aside and the small print is footer. These are semantic tags. Semantic just means "has a meaning": the tag tells the browser what the part is, not how it looks.
Div soup or semantic tags
Here's one small page written the "div soup" way. Every part is a div, and only a class name says what it is:
<div class="header">
<div class="title">Web Basics</div>
<div class="nav">
<a href="#">Lessons</a>
<a href="#">Tasks</a>
<a href="#">Sign up</a>
</div>
</div>
<div class="main">
<div class="article">
<div class="lesson">Lesson 2: Page structure</div>
<p>Every page has a top, a middle and a bottom.</p>
</div>
<div class="aside">Tip: one main part per page.</div>
</div>
<div class="footer">Made by Emma Clarke</div>
And the same page with semantic tags:
<header>
<h1>Web Basics</h1>
<nav>
<a href="#">Lessons</a>
<a href="#">Tasks</a>
<a href="#">Sign up</a>
</nav>
</header>
<main>
<article>
<h2>Lesson 2: Page structure</h2>
<p>Every page has a top, a middle and a bottom.</p>
</article>
<aside>Tip: one main part per page.</aside>
</main>
<footer>Made by Emma Clarke</footer>
Open both in a browser and every word sits in the same spot, same size, same colour. The difference is underneath. The browser can't read class names like "header"; it can read the header tag.
Look at the semantic version from the top. The header holds the h1, Web Basics, and a nav with three links. main is the part only this page has. Inside it, the article is one complete story and the aside is a side note, our tip. The footer carries the small print.
Same styles, fewer names to invent
The CSS shows the second win. In the div soup version every rule needs a class:
.header { background: #1E3A8A; color: white; padding: 10px 20px; }
.title { font-size: 24px; font-weight: bold; margin-bottom: 4px; }
.nav a { color: #BFDBFE; margin-right: 16px; }
With semantic tags, the tag name is already there, so the selector is just the tag:
header { background: #1E3A8A; color: white; padding: 10px 20px; }
h1 { font-size: 24px; margin: 0 0 4px; }
nav a { color: #BFDBFE; margin-right: 16px; }
Same colours, same spacing, and the page needs no invented class names for its parts.
The tags become landmarks
Open Chrome DevTools and look at the accessibility tree for the semantic page. Five rows stand out:
These are called landmarks. The two headings also keep their levels, h1 at level one and h2 at level two, which gives the page an outline. This tree is what screen readers read out and what search engines get.
Same look, three differences
- Screen readers can jump. A blind user hears a list of landmarks and jumps straight to one. The div soup page gives them nothing to jump to; the semantic page gives five.
- Search engines read the outline. The div soup page has no headings at all. The semantic page says h1, Web Basics, then h2, Lesson 2.
- Simpler CSS.
.headerbecomesheader.
Using the tag that says what the part is costs nothing, and everyone reading the page benefits.
A table for real data
A lesson timetable is real rows and columns, so it gets a table:
<table>
<tr>
<th>Day</th>
<th>Lesson</th>
<th>Teacher</th>
</tr>
<tr>
<td>Monday</td>
<td>Page structure</td>
<td>Emma Clarke</td>
</tr>
<tr>
<td>Thursday</td>
<td>Forms</td>
<td>Jack Miller</td>
</tr>
</table>
<!-- no tag fits? div is a plain box, span a plain piece of text -->
<div class="note">
Bring a laptop to <span class="room">Lab 3</span>.
</div>
Every tr is one row. th is a header cell, so the first row names the columns: Day, Lesson and Teacher. td is one cell of data, one row per lesson. Use a table only for real tabular data, never to lay out a page.
At the bottom are div and span. These two have no meaning at all. A div is a plain box and a span is a plain piece of text. Reach for them only when no other tag fits, for example to give "Lab 3" its own style.
Break it: two main parts
Change <aside> and </aside> to <main> and </main>. The page looks almost the same and opens without any error or warning. But the accessibility tree now shows a main with a second main inside it, and a screen reader finds two main parts. Keep it to one main per page, always.
A second break to try in the timetable: delete the first tr with the th cells. The data is still there, but nothing says which column is Day, Lesson or Teacher.
Quick recap
| Tag | Part of the page | Landmark |
|---|---|---|
header | top: title and usually the nav | banner |
nav | links around the site | navigation |
main | what only this page has (one per page) | main |
article | one complete story | - |
aside | a side note | complementary |
footer | the small print | contentinfo |
table, tr, th, td | real rows and columns of data | - |
div, span | no meaning; use when nothing else fits | - |
Try it yourself
Take the About me page from HTML tags, elements and attributes and give it a header with a nav, a main with an article, an aside and a footer. Then open DevTools, find the accessibility tree and check that all five landmarks are there.
Related course on Udemy
The Python Architect Masterclass: Full Stack to AI Engineer
Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)Related posts
One Request, Two Answers: the Same Post as an HTML Page and as JSON
Ask a Django blog for the same post twice: once as a 12,731-byte HTML page built by a template, once as 2,976 bytes of JSON built by a serializer. Compare the headers, see who builds the page, and why the server still owns every write.
A Blog Design from a Prompt: Downloading Figma Make Code and Reading App.tsx and BlogCard.tsx
Make a blog design from a prompt in Figma Make, download src.zip, unzip it with Python's zipfile module, and read the two files that matter: App.tsx with its selectedPost state and BlogCard.tsx with its props.
How a Web Page Works: HTML Tags, Elements and Attributes
A web page is a text file full of labelled pieces. Learn tags, attributes and nesting with three tiny pages, and see what breaks when an attribute or a closing tag is wrong.
HTML Forms: Labels, Names, Input Types and Where the Data Goes (GET vs POST)
Follow a sign-up form's answers out of the page: label and id, name as the key, browser validation, the query string a GET form builds, and why POST hides it. Plus the most common bug, an input with no name.
