Sub topic 9
Touch Targets and Spacing
This chapter assumes you can write basic HTML and CSS, know the box model and rem units, and can inspect elements in your browser's developer tools. It builds on the previous chapter's navigation patterns, because a navigation menu is where small targets cause the most trouble.
Why target size matters
A mouse pointer is a single pixel. A fingertip covers roughly 8 to 10 mm, and it hides the thing it is pressing. People also tap while walking, with one hand, or with shaky hands. If a link is small or sits close to another link, users hit the wrong one or miss both.
Two common guidelines give concrete numbers:
| Source | Guidance |
|---|---|
| WCAG 2.2, Success Criterion 2.5.8 (AA) | At least 24 by 24 CSS pixels, or enough spacing around smaller targets |
| WCAG 2.2, Success Criterion 2.5.5 (AAA) | At least 44 by 44 CSS pixels |
| Apple Human Interface Guidelines | About 44 by 44 points |
| Material Design | About 48 by 48 dp |
A practical rule for mobile-first work is to aim for about 44 CSS pixels on primary controls. Treat 24 pixels as the floor.
Make the target big, not just the text
The clickable area is the element's box, not the glyphs inside it. Small text does not need to be enlarged to get a larger target. Add size and padding to the link itself:
.site-nav a {
display: inline-flex;
align-items: center;
min-block-size: 44px;
min-inline-size: 44px;
padding-inline: 1rem;
}Several choices here are worth noting:
inline-flexlets the link take a height and center its text vertically.min-block-sizeandmin-inline-sizeare logical properties. They map to height and width in horizontal writing modes, and they set a floor, so longer labels can still grow.padding-inlinewidens the target without changing the text size.
A common mistake is setting display: inline on links and adding vertical padding. Vertical padding on an inline element does not increase the space it takes up in the layout, so neighbouring lines can overlap the tap area.
Spacing between targets
Size alone is not enough. Two 44-pixel buttons that touch each other still invite mistakes, because a thumb tap rarely lands exactly at the centre. Leave a gap between adjacent controls.
.action-row {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
}Using gap keeps the spacing in one place and avoids margin hacks on the first or last child. For stacked lists of links, such as a footer menu, vertical gap matters as much as horizontal gap.
Inline links inside text
Links in paragraphs are the hardest case. You cannot give each one a 44-pixel box without breaking the text flow. WCAG 2.2 exempts inline links in a sentence from the size requirement, but you can still help users:
- Keep
line-heightat 1.5 or more so lines of links do not crowd each other. - Avoid placing two links next to each other in the same sentence.
- Move important actions out of running text and into a button or a separate list.
Do not rely on hover
Touch screens have no true hover state. A control that reveals a menu or a tooltip only on :hover is unreachable for many users. Use :focus-visible for keyboard users and design so that all information is available without hover. You can still add hover styling as an enhancement, wrapped in a media query that checks for a precise pointer:
@media (hover: hover) and (pointer: fine) {
.site-nav a:hover {
background: #eef;
}
}Place controls where thumbs reach
On a phone held in one hand, the lower part of the screen is easiest to reach. Frequent actions, such as a primary "Add to basket" button, are often better placed near the bottom of the content flow than in a top corner. Do not fix this to a rule, though. Test it with your own content, since fixed bars at the bottom can also cover text.
Exercises
Exercise
A link has display: inline, padding-block: 12px and a font size of 16px. A user says it is hard to tap, and nearby lines seem to share its tap area. What change fixes the target size reliably, and why?
Show answer
Change it to display: inline-flex (or inline-block) and set min-block-size: 44px. Vertical padding on a plain inline element does not affect the line's layout height, so the tap area overlaps neighbouring lines. A block-level box formed by inline-flex or inline-block takes up the padding and minimum height as real space.
Exercise
Two 44px buttons sit side by side with no gap, and users often press the wrong one. What CSS would you add to their flex container, and what other check should you make on a touch device?
Show answer
Add gap: 0.75rem (or similar) to the container. Also check that nothing important depends on :hover, since touch screens cannot hover.