Sub topic 16
Footer markup and responsive layout
This chapter assumes you know basic HTML and CSS, the box model, and media queries. It also assumes you have read the earlier chapters on semantic navigation markup and on organizing footer content. Here you turn a planned footer into working markup and a layout that adapts to screen width.
What the footer element gives you
A footer element has two roles, depending on where it sits.
- When it is a direct child of
body(not insidearticle,aside,main,nav, orsection), browsers expose it as acontentinfolandmark. Screen reader users can jump straight to it. - When it sits inside a sectioning element such as
article, it is not a landmark. It describes only that section, for example an author line under a blog post.
Use one page-level footer per page. Do not wrap it in main, or it loses the landmark role.
Marking up link groups
The footer from the plan groups secondary links under headings. Each group is a section with a heading and a list of links.
<footer>
<nav aria-label='Footer'>
<section>
<h2>Company</h2>
<ul>
<li><a href='/about'>About</a></li>
<li><a href='/careers'>Careers</a></li>
<li><a href='/contact'>Contact</a></li>
</ul>
</section>
<section>
<h2>Legal</h2>
<ul>
<li><a href='/privacy'>Privacy policy</a></li>
<li><a href='/terms'>Terms of use</a></li>
</ul>
</section>
</nav>
<p><small>© 2026 Example Co.</small></p>
</footer>Several choices here matter.
- A labeled
nav. The page already has a primarynav. Twonavlandmarks with the same name are indistinguishable in a screen reader's landmark list, so the footer one getsaria-label='Footer'. The primary one is labeledPrimary. - Lists for links. A list announces "list, 3 items", which tells users how long each group is.
- Headings for groups. Headings let screen reader users skip between groups. Choose the heading level from the page outline. Many sites use
h2in the footer, as above. If your footer headings are purely visual labels and you do not want them in the page outline, that is a design decision to make deliberately. Do not pick a level only for its size, because CSS controls size. smallfor legal text. Thesmallelement marks side comments such as copyright and licensing. It does not mean "make this text small".
Not everything in a footer is navigation. A copyright line, an address, or a newsletter form belongs outside the footer nav. Use the address element only for contact information for the page or its nearest article or body ancestor, not for any postal address.
Layout: from one column to many
Start with the narrowest layout, which is a single stacked column. That is the default flow of block elements, so you need no CSS for it. Then add columns when there is room.
The footer markup puts the section elements directly inside the nav, so the grid goes on the nav.
footer {
padding: 2rem 1rem;
background: #f4f4f4;
color: #222;
}
footer nav {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
gap: 2rem;
}
footer ul {
margin: 0;
padding: 0;
list-style: none;
}
footer a {
display: inline-block;
padding: 0.5rem 0;
color: inherit;
}
footer a:focus-visible {
outline: 3px solid #1a5fd0;
outline-offset: 2px;
}The repeat(auto-fit, minmax(12rem, 1fr)) rule creates as many columns as fit, each at least 12rem wide. On a phone you get one column. On a wide screen you get several. No media query is needed, because the grid decides the column count from the available width.
When to add a media query
Auto-fit handles most cases. Use a media query when you want a different structure, not just a different count. For example, put the copyright line and a social links row side by side on wide screens.
.footer-bottom {
display: flex;
flex-direction: column;
gap: 1rem;
margin-top: 2rem;
}
@media (min-width: 48em) {
.footer-bottom {
flex-direction: row;
justify-content: space-between;
align-items: center;
}
}Use em in media queries so the breakpoint respects the user's default font size.
Touch targets and spacing
Footer links are usually small text in a dense list, which makes them easy to miss with a finger. The footer a rule above uses display: inline-block with vertical padding so each link has more height. WCAG 2.2 requires a target size of at least 24 by 24 CSS pixels (success criterion 2.5.8), and 44 by 44 is a common recommendation for comfortable touch. Padding on the link itself enlarges the clickable area. Margins do not.
For a stricter result, make the link fill its row.
footer li a {
display: block;
min-height: 2.75rem;
line-height: 2.75rem;
}Use this variant only if full-width rows suit your design, since each link then spans the whole column.
Colors, contrast, and focus
Footers often use a dark background with muted gray text, and that is where contrast failures appear. Normal text needs a contrast ratio of at least 4.5:1 against its background (WCAG 1.4.3). Check link text, not just paragraph text. Do not rely on color alone to show that something is a link, so keep underlines in running text or use another visible cue. In a list of links under a heading, the context makes them recognizable, but they still need a visible focus outline. If you use a dark footer, set the focus outline color to one that contrasts with the dark background, since a dark blue outline can vanish there.
Common mistakes
| Mistake | Effect | Fix |
|---|---|---|
| `footer` placed inside `main` | No `contentinfo` landmark | Place it as a direct child of `body` |
| Two `nav` elements without labels | Landmarks sound identical | Add `aria-label` to each |
| Links as plain `div` or `span` with click handlers | No keyboard access | Use `a` elements with `href` |
| Fixed pixel widths on columns | Horizontal scroll on phones | Use `minmax` and `fr` units |
| Footer headings chosen for size | Broken heading outline | Choose the level by structure, style with CSS |
| Low-contrast gray on dark | Text unreadable | Test ratios, aim for 4.5:1 or more |
Exercises
Exercise
A page has a primary nav and a footer nav. A screen reader user opens the landmarks list and sees "navigation, navigation, content info". What change fixes the ambiguity, and why does the footer landmark appear as "content info" here?
Show answer
Add a distinct accessible name to each nav, such as aria-label='Primary' and aria-label='Footer', so the list reads "Primary navigation" and "Footer navigation". The footer appears as content info (the contentinfo landmark) because it is a direct child of body, not nested in main, article, aside, nav, or section.
Exercise
Your footer grid uses repeat(auto-fit, minmax(12rem, 1fr)). The container is 40rem wide with a 2rem gap, and there are four link groups. How many columns appear, and what happens to the rest of the groups?
Show answer
Three columns fit: three columns need at least 36rem plus two gaps of 2rem, which is 40rem, and a fourth would need 52rem. The first three groups share the first row and the fourth wraps to a second row, taking the first column. Each column is wider than 12rem because 1fr shares the leftover space.