Sub topic 8
The footer: closing information and secondary links
This chapter covers the footer, the last region of the page. It assumes you know basic HTML tags and attributes, basic CSS selectors and properties, and how to inspect a page in your browser's developer tools. You should also have read the chapters on semantic elements and the header, because the footer follows the same landmark rules.
What the footer is for
The footer closes the page. Visitors scroll to it when they have not found something, or when they want information that does not belong in the main message. Typical contents are:
- A copyright line and the year.
- Links to legal pages, such as privacy and terms.
- Secondary navigation, such as help, careers, or a sitemap.
- Contact details and social links.
Keep the footer secondary. The primary actions of the page belong in the header and the main content. The footer repeats or supplements them.
The footer element
Use the footer element. When it is a direct child of body, browsers expose it as a contentinfo landmark. Screen reader users can then jump straight to it from a list of landmarks.
<footer>
<p>© 2026 Acme Bakery</p>
<a href="/privacy">Privacy</a>
</footer>A footer nested inside article or section does not become a page-level landmark. It describes only that section, for example the author and date of an article. Use one page-level footer per page.
Adding secondary navigation
If the footer has a group of links, wrap them in a nav element. A page can have several nav landmarks, so give each one a distinct accessible name with aria-label. Otherwise a screen reader announces two landmarks both called "navigation."
<footer>
<nav aria-label="Footer">
<ul>
<li><a href="/privacy">Privacy</a></li>
<li><a href="/terms">Terms</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
<p>© 2026 Acme Bakery</p>
</footer>A short list of links does not always need a nav. Use it for a real group of site links, not for a single "Privacy" link.
Where the footer sits
The footer follows main in the source order, and it should also appear at the bottom of the screen. On a short page, a footer can float up and leave empty space beneath it. The fix is the grid layout from the layout chapter: give body three rows, with main taking the remaining space.
body {
margin: 0;
min-height: 100vh;
display: grid;
grid-template-rows: auto 1fr auto;
}
footer {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 1rem;
padding: 1.5rem 2rem;
}The auto rows size the header and footer to their content. The 1fr row gives main all leftover height. The footer's own display: flex places the link group and the copyright line side by side, and flex-wrap lets them stack on narrow screens.
Common errors
- Several page-level footers. Each page should have one top-level
footer. Put section footers inside their section. - Putting the main call to action only in the footer. Most visitors never scroll that far.
- Unnamed repeated landmarks. Two
navelements withoutaria-labelare indistinguishable to screen reader users. - Placing the footer inside
main. It then stops being acontentinfolandmark. - Using
height: 100vhinstead ofmin-height. Long content then overflows the body and can overlap the footer. - Low contrast for small gray text. Footer text is often light and small. Check the contrast ratio, which should be at least 4.5:1 for body-size text.
Checking your work
Open the page in your browser, then open the developer tools. In the Elements panel, confirm that the footer is a direct child of body. Resize the window to a short height and confirm that the footer stays at the bottom. In the Accessibility panel, confirm that a contentinfo landmark exists and that the footer nav is named "Footer."
Exercise
A page has a header with <nav aria-label="Primary"> and a footer with a second <nav> that has no label. Why is this a problem for screen reader users, and what is the fix?
Show answer
A screen reader lists both as "navigation" with no way to tell them apart. Add a distinct accessible name to the footer one, for example <nav aria-label="Footer">.
Exercise
The footer on a page with very little content sits halfway up the screen. Which CSS on body keeps it at the bottom, and what does each part do?
Show answer
Use min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto;. min-height: 100vh makes the body at least as tall as the viewport. The grid gives the header and footer their natural height (auto) and gives main the remaining space (1fr), which pushes the footer down.