Sub topic 13
Putting the Whole Page Together
This chapter combines the pieces from earlier chapters into one working page. It assumes you can write basic HTML tags and attributes, use CSS selectors and properties, and open a page in a browser with developer tools. It also assumes you have read the earlier chapters on semantic elements, headings, the hero, grid and flexbox, and skip links. Here you assemble the parts in a sensible order, check them, and learn which mistakes show up most often.
The plan: build from the inside out
A page can break in many places at once if you write everything together. A more reliable order moves from the parts that don't depend on styling to the parts that do:
- Write the HTML skeleton with landmarks and no CSS.
- Fill in the heading outline.
- Add the hero and its image.
- Add the content sections.
- Add page-level layout with grid and flexbox.
- Add responsive rules.
- Add the skip link and check keyboard and screen reader behavior.
Each step leaves you with a page that still works. The unstyled page from step 1 is already usable, because semantic elements carry meaning without CSS.
Step 1 to 4: the complete HTML
The file below contains every part of the page. Save it 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>A slow-fermented loaf with a crisp crust.</p>
</article>
<article>
<h3>Rye</h3>
<p>Dense, dark, and good with soup.</p>
</article>
<article>
<h3>Seasonal pastries</h3>
<p>The selection changes with the harvest.</p>
</article>
</div>
</section>
</main>
<footer>
<p>© 2026 Acme Bakery</p>
<nav aria-label="Footer">
<a href="/privacy">Privacy</a>
</nav>
</footer>
</body>
</html>Three decisions in this file are worth examining.
- One
h1, insidemain. The hero holds the onlyh1. The section titles areh2, and the card titles areh3. No level is skipped, so a screen reader's heading list reads as a clean outline. aria-labelledbyon sections. Asectionelement only becomes a named landmark (a region) when it has an accessible name. Pointingaria-labelledbyat the heading gives it one without repeating the text.- The image carries its size. The
widthandheightattributes let the browser reserve the space before the file arrives, which prevents the content below from jumping. The path/images/hero-loaf.jpgis a placeholder. Put a real image there, or the browser will show the alt text.
Step 5 and 6: the complete CSS
Save this as styles.css in the same folder. It combines the page-level grid, the header flexbox, the responsive hero, the card grid, and the skip link.
body {
margin: 0;
min-height: 100vh;
display: grid;
grid-template-rows: auto 1fr auto;
font-family: system-ui, sans-serif;
line-height: 1.5;
}
header {
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;
}
main > section {
padding: 3rem 1.5rem;
}
.hero {
display: grid;
gap: 2rem;
}
.hero img {
max-width: 100%;
height: auto;
}
@media (min-width: 48rem) {
.hero {
grid-template-columns: 1fr 1fr;
align-items: center;
}
}
.card-grid {
display: grid;
gap: 1.5rem;
grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}
footer {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 2rem;
}
.skip-link {
position: absolute;
left: 0.5rem;
top: -3rem;
padding: 0.5rem 1rem;
background: #fff;
color: #000;
}
.skip-link:focus {
top: 0.5rem;
}The body grid does the most work here. Its three rows are auto, 1fr, and auto. The header and footer take their natural height, and main takes whatever is left. On a short page the footer therefore sits at the bottom of the window instead of floating halfway up.
The skip link is a direct child of body, and it is positioned absolutely, so it is not a grid item and does not take a row. Without that, it would become the first grid item and push the layout out of its three-row pattern.
The hero starts as a single column. That is the mobile layout, and the media query only adds the second column at 48rem (768px at the default font size). Writing the narrow layout first and widening it with min-width queries keeps the base CSS simple.
Step 7: test what you built
Open the file and run these checks in order.
- Resize. Open developer tools and use the responsive mode. Drag from 320px to 1200px. The hero should switch to two columns near 768px, and the cards should reflow without a media query.
- Short page test. Temporarily delete the card articles. The footer should still touch the bottom of the window.
- Keyboard only. Press Tab from the top. The first stop should be the skip link, visible at the top left. Press Enter and focus should move into
main. Continue tabbing to confirm every link shows a focus indicator. - Accessibility tree. In the browser's accessibility inspector, look for the landmarks: banner, two navigations (Primary and Footer), main, two regions, and contentinfo.
- Headings. List the headings with a browser extension or the screen reader's heading navigation. You should see one level 1, then level 2, then level 3 entries.
Common errors when assembling
| Symptom | Likely cause | Fix |
|---|---|---|
| Skip link does nothing | The `href` does not match the `id` on `main`, or the id is missing | Make `href="#main"` match `id="main"` exactly |
| Footer floats mid-screen on short pages | The `body` is not a grid, or has no `min-height` | Use `min-height: 100vh` with `grid-template-rows: auto 1fr auto` |
| Skip link is visible at all times | It is not positioned off-screen | Use `position: absolute` with a negative `top`, and move it back on `:focus` |
| Content jumps when the hero image loads | The `img` has no `width` and `height` | Add both attributes and `height: auto` in CSS |
| Image overflows on phones | No `max-width: 100%` | Add `max-width: 100%; height: auto;` |
| Screen reader announces two unlabeled "navigation" regions | Both `nav` elements lack distinct names | Add `aria-label="Primary"` and `aria-label="Footer"` |
| Hero image loads late | Lazy loading or low priority on the main image | Do not lazy-load it, and add `fetchpriority="high"` |
Edge cases
- Very long page, very short content. The
1frrow only stretchesmain. Ifmaincontent is taller than the window, the page scrolls normally and the footer follows the content. - Mobile browser toolbars. On some phones,
100vhis taller than the visible area while the address bar is showing. You can usemin-height: 100dvhafter100vhas a fallback pair where it is supported. - More than one
h1. HTML allows it, but the browser does not build a useful outline from nestedh1elements. Keep one per page. - Header on narrow screens. With many links, the flex row can overflow. Add
flex-wrap: wrapto the header and the nav list if you add more links than three. - A section without a heading. If you cannot give a section a heading, it probably should be a
div. Asectionis for a thematic group that deserves a title.
Summary of the model
Each part of the page has one job and one element that expresses it. The header identifies the site and holds the primary nav. The first section in main is the hero, with the page's only h1. The remaining sections in main hold the message under h2 headings. The footer closes the page with secondary links. Grid positions the major regions, flexbox arranges rows inside them, and a few media queries adapt the layout. The skip link and the accessible names make the same structure usable without a mouse or a screen.
Exercise
A visitor tabs through your page and the first focus lands on the "Menu" link in the header, not on a skip link. You do have a link with href="#main" in the HTML, but it sits inside the footer. What two changes make the skip link work as intended, and what does the CSS need so that sighted keyboard users can see it?
Show answer
Move the link to be the first element inside body so it is the first Tab stop, and make sure main has id="main" so the fragment resolves. In CSS, position the link off-screen (for example position: absolute; top: -3rem;) and bring it into view with a .skip-link:focus { top: 0.5rem; } rule, so it appears when it receives keyboard focus.
Exercise
Your page has two nav elements, one in the header and one in the footer, and a screen reader lists them both as just "navigation". Which attribute fixes this, and what values would you use?
Show answer
Add a distinct aria-label to each, such as aria-label="Primary" on the header nav and aria-label="Footer" on the footer nav. Each landmark then has a unique accessible name.
Exercise
On a page with only one short paragraph in main, the footer appears in the middle of the window. Which two declarations on body bring it to the bottom, and why does the 1fr row work?
Show answer
Use min-height: 100vh together with display: grid; grid-template-rows: auto 1fr auto;. The header and footer rows take their content height, and the 1fr row takes all remaining space, so main stretches and pushes the footer to the bottom of the window.