Sub topic 8
Target size and spacing
This chapter covers how large clickable elements should be, how far apart they should sit, and how to build both with CSS. It assumes you know basic HTML, the CSS box model (content, padding, border, margin), and how to inspect an element in your browser's developer tools. It builds on the button styling from the earlier chapters, where the .btn class already sets min-height: 44px. Here you will see why that number was chosen and what else it depends on.
Why target size matters
A target is the area that responds when a user clicks, taps, or activates it. If the target is too small, people miss it and hit a neighbor instead. Small targets cause errors for several groups:
- Touch users, because a fingertip covers roughly 10 mm of the screen and is imprecise.
- People with tremors, limited dexterity, or motor impairments, who may not be able to place a pointer accurately.
- Mouse users on laptops with trackpads, or anyone working in a moving vehicle.
- People with low vision, who often zoom in but still need predictable hit areas.
A missed tap is more than an annoyance. A wrong tap can trigger a different action, such as "Delete" instead of "Edit", and the user has to notice and undo it.
Size also works as a signifier. A button that is generously sized and padded reads as pressable. A tiny, tightly packed row of text links reads as small print.
The numbers to know
Several standards and guidelines give minimum sizes. They differ in strictness and in how they measure.
| Source | Minimum | Level or status | Notes |
|---|---|---|---|
| WCAG 2.2, Success Criterion 2.5.8 Target Size (Minimum) | 24 by 24 CSS pixels | Level AA | Exceptions for spacing, inline text, user agent controls, and essential presentation |
| WCAG 2.1, Success Criterion 2.5.5 Target Size | 44 by 44 CSS pixels | Level AAA | Stricter, with fewer exceptions |
| Apple Human Interface Guidelines | 44 by 44 points | Guideline | Applies to touch targets on iOS |
| Material Design | 48 by 48 dp | Guideline | Applies to touch targets on Android, with about 8 dp between targets |
A CSS pixel is not a device pixel. Browsers scale CSS pixels so that 1 CSS pixel looks about the same size across screens with different pixel densities. Measure targets in CSS pixels, which is what DevTools shows.
A practical rule for most sites is to treat 24 by 24 CSS pixels as the floor you must not go below, and aim for 44 by 44 for primary controls, especially on touch devices.
What the 24 pixel rule actually allows
WCAG 2.5.8 does not require every target to be 24 by 24 pixels. A target passes if any one of these holds:
- Size: the target is at least 24 by 24 CSS pixels.
- Spacing: the target is smaller, but a circle of 24 CSS pixel diameter centered on it does not overlap another target or another target's circle.
- Equivalent: another control on the same page performs the same function and meets the size requirement.
- Inline: the target sits inside a sentence or its size is constrained by the surrounding line height.
- User agent control: the browser draws the control and the page does not modify its size.
- Essential: a particular size or presentation is legally or functionally required.
The spacing exception explains why a row of small icons can pass if there is enough room between them. It also means that spacing and size trade against each other.
Where the size comes from: padding, not font size
The visible text of a link or button is usually smaller than the target you want. Create the extra area with padding or a minimum height. Padding is part of the clickable area for links and buttons, so it enlarges the target without changing the text.
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 44px;
min-width: 44px;
padding: 0 1.25rem;
}Here min-height guarantees the height even for one-word labels, and min-width stops a short label such as "OK" from collapsing to a narrow strip. The horizontal padding supplies width for longer labels.
Use min-height and min-width rather than fixed height and width. A fixed height breaks when the user increases the browser's default font size or when a label wraps onto two lines, because the text then overflows the box. A minimum lets the button grow.
Use relative units where it helps
Pixels are fine for a minimum touch target. For padding that should scale with text size, rem or em works better, because the target grows when users enlarge their text.
.btn {
min-height: 44px;
padding: 0.75em 1.25em;
}In this version the padding follows the button's font size, and min-height sets the lower bound.
Inline links are a special case
Links inside a paragraph take their height from the line box, so you cannot freely add padding to them without disturbing the text layout. Vertical padding on an inline element does not push neighboring lines apart. WCAG 2.5.8 exempts inline targets for this reason.
That exemption is permission, not a recommendation. Two things still help:
- Keep body text at a comfortable size (16 px or larger) with a line height of about 1.5, so each line of a link is a reasonable tap height.
- Avoid placing several links next to each other in running text with only a space between them.
For lists of links, such as navigation menus, footers, and related-article lists, the exemption does not apply. These are standalone targets, so give each link block-level height.
.nav a {
display: inline-block;
min-height: 44px;
line-height: 44px;
padding: 0 0.75rem;
}Setting line-height equal to the height centers a single line of text vertically. For labels that might wrap, use flexbox instead, as in the button example:
.nav a {
display: inline-flex;
align-items: center;
min-height: 44px;
padding: 0 0.75rem;
}Spacing between targets
Size alone is not enough. Two 44 pixel buttons that touch each other still invite mis-taps, because the finger lands on the boundary. Spacing provides a buffer.
A common range is 8 px between adjacent targets, as Material Design suggests. Use gap on a flex or grid container, since it only adds space between items and does not need margin hacks.
.actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
}flex-wrap: wrap lets the buttons move to a second row on narrow screens instead of shrinking. gap applies in both directions when items wrap, so the rows are also separated.
Spacing matters most for destructive or opposite actions. Place "Delete" away from "Save" so a slip does not do damage.
<div class="actions">
<button type="button" class="btn">Save changes</button>
<button type="button" class="btn btn--secondary">Cancel</button>
</div>Making the hit area bigger than the visual
Sometimes the design calls for a small visible element, such as a 16 px icon or a thin text link, but the target should still be large. You can enlarge the hit area without changing how the element looks. The standard technique uses a pseudo-element that extends beyond the element's box.
.icon-btn {
position: relative;
width: 24px;
height: 24px;
padding: 0;
border: 0;
background: transparent;
cursor: pointer;
}
.icon-btn::after {
content: "";
position: absolute;
inset: -10px;
}The ::after box is a child of the button, so clicks on it count as clicks on the button. inset: -10px pushes each edge 10 px outward, which turns a 24 px button into a 44 px target. The button must have position: relative so the pseudo-element is positioned against it.
A simpler alternative is to give the button padding and use a negative margin to cancel the layout effect:
.icon-btn {
padding: 10px;
margin: -10px;
}The padding enlarges the target, and the negative margin pulls the box back so surrounding layout does not move. The negative margin approach can cause overlap with neighbors if you are not careful, so check it in DevTools.
Watch for overlapping hit areas
An enlarged hit area can overlap the target next to it. When two targets overlap, the one later in the document (or with a higher z-index) wins the click, and the other loses part of its area. If you expand hit areas, keep the spacing large enough that the expanded areas stay separate. Otherwise you have only moved the problem.
Common mistakes
- Fixed heights on buttons. They clip text when the user zooms or changes the font size. Use
min-height. - Padding only on the text span. If the padding is on an inner element rather than on the
<a>or<button>, the extra area is not clickable. - Icon-only buttons at icon size. A 16 px icon with no padding is a 16 px target. Add padding or a pseudo-element.
- Tightly stacked list links. A vertical list of links at 14 px text with no padding gives targets under 20 px tall and almost no gap.
- Relying on the spacing exception to justify tiny targets. It is a minimum for compliance, not a good design target.
- Making only the text of a card clickable. If a whole card represents one destination, make the whole card the target. Use one real link in the card and stretch its hit area with a pseudo-element.
.card {
position: relative;
}
.card a::after {
content: "";
position: absolute;
inset: 0;
}This works because the card is the positioned ancestor, so the link's pseudo-element covers the entire card. Keep a single link per card. If the card contains several links, the stretched area would hide the others.
How the pieces fit together
Checking in the browser
You can verify target size without writing any code:
- Open DevTools and select the element in the Elements panel.
- Hover the node. The overlay shows the element's dimensions and highlights its padding area.
- Open the Computed tab and read the box model diagram. Confirm the total of content, padding, and border is at least 24 by 24, ideally 44 by 44.
- For pseudo-elements, expand the element in the Elements panel and select
::after. Check its size and position. - Use device emulation to view the page at a phone width, then test real taps on a physical phone when you can.
Accessibility audits such as Lighthouse and axe flag some target size problems, but they cannot judge every case, such as the spacing exception or hit areas created by pseudo-elements. Treat them as a first pass.
Summary of rules
- Make standalone targets at least 24 by 24 CSS pixels, and aim for 44 by 44 for primary and touch controls.
- Build size with
min-height,min-width, and padding on the clickable element itself. - Leave at least 8 px between adjacent targets, more for destructive actions.
- Inline links in text are exempt from the size rule, but keep text size and line height generous.
- Enlarge small visuals with padding or a pseudo-element, and check for overlap.
Exercise
A toolbar has three icon buttons, each 20 by 20 CSS pixels, placed side by side with no gap. Name two changes that would bring it to a safe state for touch users, and give the CSS for one of them.
Show answer
Either enlarge each hit area to about 44 by 44 pixels, or add spacing between the buttons so a 24 pixel circle around each does not overlap its neighbors. Enlarging works best because it helps touch users directly. Example: .icon-btn { position: relative; } .icon-btn::after { content: ""; position: absolute; inset: -12px; } makes each button 44 by 44. Add gap: 8px on the toolbar container so the enlarged areas do not overlap.
Exercise
A developer sets .btn { height: 44px; } and a user with a larger browser font size reports that long labels spill out of the buttons. What is the fix and why does it work?
Show answer
Replace height with min-height: 44px and let the content determine the rest, using padding in em or rem. A minimum guarantees the target size while allowing the box to grow when text wraps or scales, so the label stays inside the button.
Exercise
Why can a vertical list of footer links not rely on the inline exemption in WCAG 2.5.8?
Show answer
The exemption covers links inside a sentence or block of text, where the line height limits the target size. Footer links are standalone targets, so they must meet the 24 by 24 pixel size or the spacing exception. Giving each link display: inline-flex, align-items: center, and min-height: 44px solves it.