Sub topic 8
The footer: closing information and secondary links
The footer closes the page. Visitors reach it after they have read the main content, or when they need something the header did not offer, such as contact details, legal links, or a sitemap. This chapter covers what belongs in a footer, how to mark it up, and how to style it so it stays at the bottom of the page.
Prerequisites
This chapter assumes you can write basic HTML tags and attributes, and basic CSS selectors and properties. It also assumes you can open a page in a browser and inspect it with developer tools. It builds on the earlier chapters on semantic elements and on the page skeleton with header, main, and footer.
What a footer is for
A footer holds information that is useful but not central to the page's main message. Typical contents:
- Copyright notice and the year.
- Links to legal pages, such as privacy policy and terms of use.
- Secondary navigation: links that matter but do not deserve a place in the primary header navigation.
- Contact details, such as an address, email, or phone number.
- Social media links.
- A short description of the site or organization.
The header answers "where am I and where can I go?". The footer answers "what else should I know, and where do I go if I did not find it above?". Keep the primary call to action in the hero and content sections. Do not hide it in the footer.
The footer element
HTML provides the footer element for this role. It is a semantic element, which means its name tells browsers and assistive technology what the content is.
A footer has two meanings that depend on where it sits:
- When it is a direct child of
body(not nested insidearticle,aside,main,nav, orsection), it represents the footer of the whole page. Browsers expose it to assistive technology as acontentinfolandmark. - When it is nested inside a sectioning element such as
articleorsection, it represents the footer of that section only, for example an author line or a list of tags. It is not a page-level landmark.
Because of this, a page can contain several footer elements, but only the one that is a direct child of body is the page footer. Keep it outside main.
<footer>
<p>© 2026 Acme Bakery</p>
<a href="/privacy">Privacy</a>
</footer>This is the minimal footer from the page skeleton. It works, but real sites usually need more structure.
A fuller footer
A footer with several kinds of content is easier to use when you group the links. Use a nav element for each group of links, and give each one its own accessible name with aria-label. Screen reader users can then tell the primary navigation from the footer navigation.
<footer>
<div class="footer-brand">
<a href="/">Acme Bakery</a>
<p>Fresh bread, baked every morning.</p>
</div>
<nav aria-label="Footer">
<h2>Explore</h2>
<ul>
<li><a href="/menu">Menu</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
<address>
12 Baker Street<br>
Springfield<br>
<a href="mailto:[email protected]">[email protected]</a>
</address>
<p class="legal">
© 2026 Acme Bakery ·
<a href="/privacy">Privacy</a> ·
<a href="/terms">Terms</a>
</p>
</footer>Points to notice:
- The
addresselement is for contact information for the nearestarticleorbodyancestor. Inside a page footer, it describes the page or site owner. Do not use it for arbitrary postal addresses, such as the address of a venue mentioned in an article. - The
navhasaria-label="Footer". The header's navigation is labeled "Primary". Distinct names let screen reader users choose between them in a list of landmarks. - Headings inside the footer, such as "Explore", are
h2elements here because they sit below the page's singleh1. Whether to use headings in a footer is a judgment call. They help when the footer has several distinct groups, and they are noise when it has one line of text. - Not every group of links needs a
nav. Reservenavfor major blocks of navigation. A single "Privacy | Terms" line inside a legal paragraph does not need to be a landmark.
Footer content patterns
Footers tend to follow a few patterns. Choose the one that matches how much your site has to offer.
| Pattern | Contents | Good for |
|---|---|---|
| Minimal | Copyright and one or two legal links | Small sites, landing pages |
| Link columns | Several groups of links under short headings | Larger sites with many sections |
| Contact focus | Address, phone, email, opening hours | Local businesses |
| Fat footer | Link columns, contact details, newsletter sign-up, social links | Large organizations and documentation sites |
A larger footer is not automatically better. Each extra link competes for attention and adds to the amount a keyboard user must tab through. Include only links that a visitor might plausibly need at the end of a page.
Where the footer sits in the document
The following diagram shows how the footer relates to the other top-level parts of the page, and which footers count as the page footer.
Keeping the footer at the bottom
On a short page, such as a "thank you" page with one paragraph, a footer placed after the content rises to the middle of the screen. This looks broken. The fix is to make the page at least as tall as the viewport and let main take the leftover space.
body {
margin: 0;
min-height: 100vh;
display: grid;
grid-template-rows: auto 1fr auto;
}The three rows map to the three children of body. auto makes the header and footer only as tall as their content, and 1fr gives main whatever space remains. If the page is taller than the viewport, min-height lets it grow and the footer follows the content.
This pattern assumes body has exactly three direct children. If you add a skip link as a fourth child before the header, the rows no longer match. The skip link is positioned absolutely in the earlier example, so it does not take part in the grid layout, and the three rows still apply to the header, main, and footer. If you add other in-flow children, adjust grid-template-rows or wrap the page in a container.
A common alternative uses flexbox:
body {
margin: 0;
min-height: 100vh;
display: flex;
flex-direction: column;
}
main {
flex: 1;
}Here flex: 1 makes main grow to absorb free space. Both approaches work. Grid states the intended row sizes in one place. Flexbox needs a rule on a different element.
A note on 100vh: on some mobile browsers, 100vh is measured as if the address bar were hidden, so the page can be slightly taller than the visible area. Newer browsers support 100dvh, which follows the actual visible height. You can write min-height: 100vh first and min-height: 100dvh after it. Browsers that do not understand dvh ignore the second line and keep the first.
Laying out the footer's contents
Inside the footer, use grid for columns and flexbox for rows of inline items. The following CSS places the brand, link group, and address side by side on wide screens and stacks them on narrow ones. The auto-fit and minmax() combination needs no media query.
footer {
padding: 2rem 1.5rem;
background: #1f1a17;
color: #f5efe9;
display: grid;
gap: 2rem;
grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}
footer a {
color: inherit;
}
footer ul {
list-style: none;
margin: 0;
padding: 0;
display: grid;
gap: 0.5rem;
}
footer .legal {
grid-column: 1 / -1;
margin: 0;
font-size: 0.875rem;
}The .legal line uses grid-column: 1 / -1 to span every column, so it forms its own row beneath the others. The -1 means "the last grid line", so the rule keeps working however many columns the grid creates.
Common errors
- Putting the footer inside
main. A footer insidemainis not a page-level landmark. Move it to be a direct child ofbody. - Using
div class="footer"instead offooter. The page then has nocontentinfolandmark, and screen reader users cannot jump to it. - Using several unlabeled
navelements. Assistive technology announces each one as "navigation" with no way to tell them apart. Addaria-labelto each. - Low contrast. Footers often use a dark background with gray text. Check that text and link colors meet a contrast ratio of at least 4.5:1 for normal-sized text, and that links are distinguishable from surrounding text.
- Small link targets. Tightly packed footer links are hard to tap on a phone. Give links enough padding or spacing that each one is easy to hit.
- Putting essential content only in the footer. If visitors need it to complete a main task, it belongs in the header or the main content too.
- Forgetting the year. A copyright year that is several years old makes a site look abandoned. Generate it automatically in your template or build step if you can.
Checking your work
Open the page in a browser and try these checks:
- Open developer tools and inspect the footer. Confirm it is a direct child of
body. - In the browser's accessibility tree view, find the
contentinfolandmark. If it is missing, the footer is nested inside another element or is not afooterelement. - Resize the window to a narrow width. The columns should stack, and no text should overflow.
- Load a page with very little content. The footer should sit at the bottom of the window.
- Press Tab repeatedly. Focus should reach every footer link in a logical order, and each focused link should show a visible outline.
Exercise
A page has a footer element inside main that contains the copyright line and the privacy link. A screen reader user says they cannot jump to the page footer with their landmark shortcut. What is wrong, and how do you fix it?
Show answer
A footer nested inside main is the footer of that sectioning context, not the page, so the browser does not expose it as a contentinfo landmark. Move the footer out of main so it is a direct child of body, placed after the closing </main> tag.
Exercise
Write the CSS for a three-row page layout (header, main, footer) so that the footer stays at the bottom of the window on a short page. Which row should be 1fr, and why?
Show answer
Use body { margin: 0; min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }. The middle row, which holds main, is 1fr so it takes all the space left after the header and footer take only the height their content needs. This pushes the footer to the bottom edge when the content is short.
Exercise
Your footer has a navigation block with Menu, About, and Contact links, and the header also has a navigation block. Both are nav elements. What attribute should you add to each, and what values would you choose?
Show answer
Add aria-label to each so screen reader users can tell them apart. For example, aria-label="Primary" on the header's nav and aria-label="Footer" on the footer's nav.