Sub topic 13
Putting the whole page together
This chapter combines the parts from earlier chapters into one working page. It assumes you know basic HTML tags, CSS selectors and properties, and how to open a page in a browser and use its developer tools.
Build in layers
Assemble the page in this order. After each step, check the result in the browser before you move on.
- Write the HTML skeleton with landmarks and the heading outline.
- Add the skip link and accessible names.
- Add CSS for the page-level layout.
- Add responsive rules.
- Test with the keyboard and the developer tools.
Content and structure come first because they work even if the CSS fails to load. CSS then changes how the page looks, not what it means.
The complete markup
Save this as index.html.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Acme Bakery</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<a class="skip-link" href="#main">Skip to main content</a>
<header>
<a href="/">Acme Bakery</a>
<nav aria-label="Primary">
<ul>
<li><a href="/menu">Menu</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
</header>
<main id="main">
<section class="hero" aria-labelledby="hero-title">
<div class="hero-text">
<h1 id="hero-title">Fresh bread, baked every morning</h1>
<p>Order ahead and pick up warm loaves on your way to work.</p>
<a class="button" href="/menu">See the menu</a>
</div>
<img src="/images/hero-loaf.jpg" alt="A basket of freshly baked loaves" width="800" height="600" fetchpriority="high">
</section>
<section aria-labelledby="specialties-title">
<h2 id="specialties-title">Our specialties</h2>
<div class="card-grid">
<article><h3>Sourdough</h3><p>Slow-risen and crusty.</p></article>
<article><h3>Rye</h3><p>Dense, dark, and tangy.</p></article>
<article><h3>Pastries</h3><p>Seasonal fillings, changed monthly.</p></article>
</div>
</section>
</main>
<footer>
<p>© 2026 Acme Bakery</p>
<nav aria-label="Footer">
<a href="/privacy">Privacy</a>
</nav>
</footer>
</body>
</html>The outline has one h1, one h2 for the second section, and h3 headings inside the cards. No heading level is skipped. The two nav elements have different aria-label values, so a screen reader can tell them apart.
The complete stylesheet
Save this as styles.css next to the HTML file.
body {
margin: 0;
min-height: 100vh;
display: grid;
grid-template-rows: auto 1fr auto;
font-family: system-ui, sans-serif;
}
header, footer {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 2rem;
}
header nav ul {
display: flex;
gap: 1.5rem;
list-style: none;
margin: 0;
padding: 0;
}
.hero {
display: grid;
gap: 2rem;
padding: 3rem 1.5rem;
}
.hero img {
max-width: 100%;
height: auto;
}
.card-grid {
display: grid;
gap: 1.5rem;
grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}
main > section:not(.hero) {
padding: 2rem 1.5rem;
}
@media (min-width: 48rem) {
.hero {
grid-template-columns: 1fr 1fr;
align-items: center;
}
}
.skip-link {
position: absolute;
left: 0.5rem;
top: -3rem;
padding: 0.5rem 1rem;
background: #fff;
color: #000;
}
.skip-link:focus {
top: 0.5rem;
}Grid on the body gives the header and footer their natural height and gives main the remaining space. The skip link is absolutely positioned, so it does not take one of the three grid rows.
Test the result
Run these checks in order.
- Press Tab once after the page loads. The skip link should slide into view. Press Enter and focus should move into
main. - Narrow the window below 48rem. The hero should become one column and the cards should stack.
- Open a very short page. The footer should still sit at the bottom of the window.
- Open the Accessibility panel in your browser's developer tools. Check that the landmarks list shows banner, two navigation regions, main, and contentinfo.
Common errors
- Forgetting the
viewportmeta tag. Phones then render the page at desktop width and your media queries never match. - Giving two
navelements the same label, or none. Screen reader users cannot tell them apart. - Putting the skip link anywhere except first in the
body. The first Tab press must reach it. - Omitting
widthandheighton the hero image. The text jumps down when the image loads.
Exercise
You add a second <main> element to hold a newsletter signup below the cards. A screen reader now reports two main landmarks. What should you do instead, and what do you need to add so the new region has a name?
Show answer
Keep one main per page and put the signup in a <section> inside it. Give the section an accessible name, for example aria-labelledby pointing at an h2 such as "Newsletter". This also keeps the heading outline correct.