Sub topic 2
Structure the page with semantic elements
This chapter assumes you can create and save an HTML file, open it in a browser, and write a basic HTML document with <!DOCTYPE html>, <html>, <head> and <body>. If you haven't done that yet, go back to the previous chapter first.
What "semantic" means
A semantic element describes the role of its content. A <div> says nothing about what it holds. A <nav> says "this is a group of navigation links". Browsers, search engines and screen readers all use these roles. A screen reader user can jump straight to the main content or the navigation without listening to the whole page.
Semantic elements that mark the large regions of a page are called landmarks. Here are the ones you will use on a one-page site.
| Element | Role | Typical use on this site |
|---|---|---|
| `<header>` | Introductory content | Site name and navigation |
| `<nav>` | Major navigation links | Links to page sections |
| `<main>` | The page's primary content | Everything between header and footer |
| `<section>` | A themed group of content, usually with a heading | About, Projects, Contact |
| `<footer>` | Closing content | Copyright notice |
Build the skeleton
Put these elements inside <body>. The id on each section gives later chapters something to link to.
<!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">
<h1>Jane Doe</h1>
<p>I build small, fast websites.</p>
</section>
<section id="projects">
<h2>Projects</h2>
</section>
<section id="contact">
<h2>Contact</h2>
<p><a href="mailto:[email protected]">[email protected]</a></p>
</section>
</main>
<footer>
<p>© 2026 Jane Doe</p>
</footer>
</body>
</html>Open the file in your browser. It looks plain, because there is no CSS yet. The structure is already in place, though.
Rules that prevent common errors
- Use one
<main>per page. It must not sit inside<header>,<footer>,<nav>or another landmark. - Give each
<section>a heading. A section without a heading is usually better written as a<div>. - Use
aria-labelon<nav>when a page has more than one navigation area. Screen readers then announce each one by name. - Pick elements for their meaning, not their looks. Don't use
<section>just to get a block that you can style. CSS handles appearance. - Use
<div>when no semantic element fits, for example to wrap items for layout.
Check your structure
A quick test is to read only the tags. If the outline reads like a table of contents (header, nav, main with three sections, footer), the structure is sound. Browser developer tools also show an accessibility tree that lists the landmarks the browser found.
Exercise
Your page has a top navigation bar and a second list of links in the footer. Which element should wrap each list, and what attribute helps screen reader users tell them apart?
Show answer
Wrap each list of links in a <nav> element. Give each one an aria-label, for example aria-label="Main" for the top bar and aria-label="Footer" for the footer list, so screen readers announce them as distinct landmarks.
Exercise
A teammate wraps the whole page, including the header and footer, in a single <main> element. What is wrong with this, and how do you fix it?
Show answer
<main> should hold only the page's primary content, and a page should have just one. Move <header> and <footer> outside it so they are siblings of <main> inside <body>.