Sub topic 12
Accessible spacing, touch targets and text-spacing overrides
This chapter assumes you know the box model, rem and em units, and how to apply a spacing scale with padding, margin and gap. It covers three accessibility checks for the groupings you have built: touch target size, text-spacing overrides, and whether your groups survive when users change spacing.
Why spacing is an accessibility concern
White space tells sighted users which items belong together. It also decides whether a finger or pointer can hit the right control. Some users also override your spacing with their own stylesheets or browser extensions. If your grouping depends on one fixed set of values, it can break for them.
Touch targets
A touch target is the area that responds to a tap or click. WCAG 2.2 sets two thresholds:
| Criterion | Level | Requirement |
|---|---|---|
| 2.5.8 Target Size (Minimum) | AA | At least 24 by 24 CSS pixels, or enough spacing around smaller targets |
| 2.5.5 Target Size (Enhanced) | AAA | At least 44 by 44 CSS pixels |
The spacing exception in 2.5.8 matters here. A small target passes if a 24 pixel circle centered on it does not overlap another target's circle. So white space can make a small control compliant.
Prefer padding over margin to enlarge a target. Padding is part of the element's clickable area, but margin is not.
.icon-button {
padding: var(--space-3);
min-inline-size: 2.75rem;
min-block-size: 2.75rem;
}
.toolbar {
display: flex;
gap: var(--space-2);
}Here 2.75rem is 44 pixels at the default font size. The gap keeps neighboring buttons apart, so a missed tap does not trigger the wrong one.
Text-spacing overrides
WCAG 1.4.12 Text Spacing (AA) requires that content still works when a user sets all of these at once:
- Line height at least 1.5 times the font size.
- Paragraph spacing at least 2 times the font size.
- Letter spacing at least 0.12 times the font size.
- Word spacing at least 0.16 times the font size.
Nothing may be clipped, hidden or overlapped. Text grows, so containers must be able to grow with it.
You can test this with a stylesheet that applies those values. Load it as a user style, or paste it into the browser's developer tools.
* {
line-height: 1.5 !important;
letter-spacing: 0.12em !important;
word-spacing: 0.16em !important;
}
p {
margin-bottom: 2em !important;
}Common failures
- A fixed
heighton a button, card or banner clips the larger text. Usemin-block-sizeor let content set the height. - Absolute positioning places labels over neighboring text once text grows.
- A
white-space: nowrapheading overflows its container. - Spacing set in
pxstays small while the text grows. Spacing inremoremscales with the type.
Check your groups too. If paragraph spacing becomes 2em, the gap between paragraphs may match or exceed the gap between sections. Then the proximity principle fails, because everything looks equally separated. Section gaps from your scale should stay clearly larger than paragraph gaps. A flow rule with a custom property helps, because you can adjust one value.
A short checklist
- Make every interactive target at least 24 by 24 CSS pixels, and aim for 44 where space allows.
- Add padding to enlarge targets, and
gapto separate them. - Use
min-sizes andremoremunits so containers grow with text. - Apply the override stylesheet and look for clipping, overlap and merged groups.
- Keep the step between spacing levels large enough to survive a doubling of paragraph spacing.
Exercise
A row of small icon links has 16 by 16 pixel targets with 4 pixels of space between them. Name two ways to meet WCAG 2.5.8, and say why adding margin to each link is a weaker choice than adding padding.
Show answer
Enlarge each target to at least 24 by 24 pixels with padding, or increase the space so a 24 pixel circle centered on each link does not overlap its neighbors' circles (spacing exception). Padding extends the clickable area of the link itself. Margin adds empty space outside it that does not respond to taps, so it only helps through the spacing exception, not by enlarging the target.
Exercise
After you apply the text-spacing test stylesheet, a card title is cut off and the gap between two paragraphs equals the gap between two sections. What do you change for each problem?
Show answer
Replace the fixed height on the card with min-block-size (or no height) so it grows with its text. Then keep section spacing clearly larger than paragraph spacing, for example by using a larger step on your scale for sections, so the grouping still reads.