Sub topic 2
Structure the page with semantic elements
This chapter assumes you can write a valid HTML document with <!DOCTYPE html>, <html lang>, <head> and <body>. It also assumes you know what an element, an attribute and a heading are. You will replace anonymous containers with elements that describe what each part of the page is for.
What "semantic" means
A semantic element tells the browser, search engines and assistive technology what its content is, not only how it looks. A <div> has no meaning. A <nav> says "this is a group of navigation links."
You get three practical benefits:
- Screen reader users can jump straight to the main content or the navigation instead of listening to the page from the top.
- Browsers apply sensible defaults, such as reader mode and keyboard behavior.
- Your own markup becomes easier to read and maintain, because the element names describe the page.
Semantic elements have no built-in visual design beyond minor defaults. You still style them with CSS later. Choosing <nav> over <div class="nav"> changes the meaning of the page and nothing about its looks.
The landmark elements
Landmarks are the large regions of a page that assistive technology can list and jump between. The table shows the elements you will use on a one-page site, and the landmark role each exposes.
| Element | Purpose | Landmark role |
|---|---|---|
| `<header>` | Introductory content for the page or a section, such as a logo and navigation | `banner`, only when it is a direct child of `<body>` |
| `<nav>` | A block of major navigation links | `navigation` |
| `<main>` | The central content that is unique to this page | `main` |
| `<section>` | A themed group of content, normally with a heading | `region`, only when it has an accessible name |
| `<article>` | A self-contained piece that makes sense on its own | none |
| `<aside>` | Content related to, but separate from, the surrounding content | `complementary` |
| `<footer>` | Closing content for the page or a section, such as copyright and contact details | `contentinfo`, only when it is a direct child of `<body>` |
The "only when" qualifiers matter. A <header> inside an <article> is just that article's heading area. It is not a page-level banner. The same applies to <footer>.
A page skeleton
Here is the body structure for the personal site. It uses one <header>, one <nav>, one <main> with three sections, and one <footer>.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Jane Doe | Web Developer</title>
</head>
<body>
<header>
<nav aria-label="Main">
<ul>
<li><a href="#about">About</a></li>
<li><a href="#projects">Projects</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section id="about" aria-labelledby="about-title">
<h1 id="about-title">Jane Doe</h1>
<p>I build small, fast websites.</p>
</section>
<section id="projects" aria-labelledby="projects-title">
<h2 id="projects-title">Projects</h2>
</section>
<section id="contact" aria-labelledby="contact-title">
<h2 id="contact-title">Contact</h2>
<p><a href="mailto:[email protected]">[email protected]</a></p>
</section>
</main>
<footer>
<p>© 2026 Jane Doe</p>
</footer>
</body>
</html>The id attributes on the sections are the targets for the anchor links in the navigation. A later chapter covers in-page navigation in detail. The aria-labelledby attribute points at the heading's id. That gives each section an accessible name, which turns it into a region landmark.
The diagram shows how the elements nest.
How the browser and assistive technology use this
Browsers build an accessibility tree alongside the page's element tree. Each element contributes a role, a name and a state. A screen reader reads from this tree. When it finds a navigation landmark with the name "Main", it can announce "Main navigation" and let the user jump to it with a single key.
This is why the aria-label="Main" on the <nav> matters. If you add a second navigation later, for example in the footer, both need distinct names such as "Main" and "Footer". Otherwise a user hears two identical "navigation" entries and cannot tell them apart.
Choosing between section, article, aside and div
Use this order of questions for each block of content:
- Is it the unique central content of the page? Use
<main>, once only. - Is it a group of major navigation links? Use
<nav>. - Would it still make sense if you copied it to another site, such as a blog post or a project write-up? Use
<article>. - Is it a themed group that would have its own heading? Use
<section>. - Is it tangential, such as a sidebar note or a pull quote? Use
<aside>. - Is it only a wrapper for styling or layout? Use
<div>.
<div> is not wrong. You will still use it when a CSS layout needs an extra wrapper, and an unneeded semantic element is worse than a plain <div>. A <section> without a heading is a warning sign. If you cannot give it a heading, it probably should be a <div>.
In the project list, each project card is a good candidate for <article>, because it stands on its own with its own title and description:
<section id="projects" aria-labelledby="projects-title">
<h2 id="projects-title">Projects</h2>
<div class="project-list">
<article>
<h3>Recipe Finder</h3>
<p>A small search page for home cooks.</p>
</article>
<article>
<h3>Trail Notes</h3>
<p>A static site for hiking logs.</p>
</article>
</div>
</section>The div with the class project-list is a legitimate wrapper. It exists so that a Grid layout can target the cards in a later chapter.
Headings give the page its outline
Semantic elements and headings work together. Screen reader users often navigate by heading level alone, so the heading hierarchy forms a table of contents.
- Use exactly one
<h1>per page. Here it is your name or the page's main topic. - Use
<h2>for each main section, and<h3>for items inside a section. - Do not skip levels, for example from
<h2>straight to<h4>, to get a smaller font. Choose the level for the structure and size the text with CSS.
HTML defines a "document outline" algorithm in which nested sections reset heading levels. No browser or screen reader implements it, so rely on explicit heading levels only.
Common errors
- Multiple
<main>elements. A page may have only one visible<main>. Two of them confuse landmark navigation. - Putting
<main>inside<header>,<footer>,<nav>or<article>.<main>belongs at the top level of the body content. - Wrapping everything in
<section>. Using it as a generic container dilutes the meaning of real sections. Use<div>for pure layout. - Using
<nav>for every group of links. Reserve it for major navigation. A short list of links in the footer does not need one. - Choosing elements by default appearance. Do not use
<header>because it "looks like a heading" or<blockquote>to indent text. Choose by meaning and fix the look with CSS. - Missing names on repeated landmarks. If a page has more than one
<nav>, give each its ownaria-label. - Treating
<header>as always being a banner. Inside a section or article, it does not create a page-level landmark.
Trade-offs and decisions
Semantic markup costs almost nothing, but it is easy to overdo. Prefer fewer, correct elements over many loosely chosen ones. When two elements seem to fit, such as <section> and <article>, ask whether the content is self-contained. If you still cannot decide, pick the simpler <section> and give it a clear heading. The choice rarely changes the experience for readers, while a missing heading or a duplicate <main> does.
Exercise
A learner builds a page with <div id="top"> holding the links, <div id="content"> holding three headed blocks of text, and <div id="bottom"> holding a copyright line. Which semantic elements should replace each div, and what must be added if the page gets a second link list in the footer?
Show answer
Replace #top with a <header> containing a <nav aria-label="Main">. Replace #content with <main>, and turn each of the three headed blocks into a <section> with its own heading (and aria-labelledby if you want it exposed as a region). Replace #bottom with a <footer>. If the footer gets a second list of links, wrap it in its own <nav> and give it a distinct label such as aria-label="Footer", so the two navigation landmarks can be told apart.
Exercise
Why is <header> not always a banner landmark, and where does this affect the personal site?
Show answer
The banner role applies only when <header> is a direct child of <body>, so it describes the whole page. Inside an <article> or <section>, a <header> only introduces that block and creates no page-level landmark. On the personal site, the top <header> with the navigation is the banner. A <header> inside a project <article> is not.