Layouts that work for everyone
Overview
Accessibility is often discussed in terms of HTML — labels, alt text, ARIA. But layout decides whether a page still works when someone zooms to 400%, uses huge text, overrides your spacing, or turns on high-contrast mode. The good news: the modern, flexible techniques in this course pass these tests almost automatically. The problems come from fixed sizes and clipping.
This lesson covers the layout-related WCAG 2.2 requirements and how to meet them.
1. Reflow at 320px (WCAG 1.4.10)
People with low vision zoom in — often to 200% or 400%. At 400% zoom on a 1280px-wide screen, the page is laid out as if the viewport were 320 CSS pixels wide. WCAG requires that content then reflows into a single column, with no horizontal scrolling for normal text content.
Exceptions are content that genuinely needs two dimensions: data tables, maps, diagrams, toolbars in complex apps. Those may scroll in their own container.
What fails reflow:
- fixed widths (
width: 900px), min-widthon large layout containers,- grid tracks with large minimums and no
min()(minmax(400px, 1fr)), white-space: nowrapon long text,- fixed or sticky headers so tall that, at 400%, they cover most of the screen.
What passes: max-inline-size, min(…, 100%), flex-wrap, auto-fit with min(), and media/container queries that switch to one column. Test it: set your browser window to 1280px wide and zoom to 400%, or set DevTools’ responsive mode to 320px.
2. Resize text to 200% (WCAG 1.4.4)
Text must be resizable to 200% without loss of content. Browser zoom handles most of this, but some people instead increase the default font size in browser settings, which only affects rem/em-based sizes.
- Use
remfor font sizes, spacing, and media/container query breakpoints. - Avoid fixed heights on anything containing text — use
min-block-size. - In
clamp(), always include aremcomponent (clamp(1.5rem, 1rem + 2.5vw, 3rem)), as explained in Fluid sizing with clamp.
3. Text spacing (WCAG 1.4.12)
Some people with dyslexia or low vision use browser extensions or user stylesheets to increase spacing. Your layout must not lose content when these are applied:
| Property | Value |
|---|---|
| line height | 1.5 × font size |
| spacing after paragraphs | 2 × font size |
| letter spacing | 0.12 × font size |
| word spacing | 0.16 × font size |
Text grows in both directions. The classic failure is a box with a fixed height and overflow: hidden — the extra lines simply disappear. Truncation with text-overflow: ellipsis and line-clamp can also hide content; if you truncate, make sure the full text is available elsewhere (for example on the page the card links to).
Test it by pasting this into the DevTools console:
document.head.insertAdjacentHTML('beforeend', `<style>
* { line-height: 1.5 !important; letter-spacing: 0.12em !important; word-spacing: 0.16em !important; }
p { margin-block-end: 2em !important; }
</style>`);Then check that nothing is cut off or overlapping.
4. Target size (WCAG 2.5.8)
WCAG 2.2 requires interactive targets to be at least 24 × 24 CSS pixels, or to have enough space around them that a 24px circle centred on each doesn’t overlap another target. Small inline links in a sentence are exempt.
That’s the minimum; 44 × 44px (the enhanced level and Apple’s guideline) is much easier to use on touch screens and for people with tremors:
.icon-button { min-inline-size: 44px; min-block-size: 44px; display: inline-grid; place-items: center; }Gaps between targets matter too: a row of icons with no gap is easy to mis-tap.
5. Focus visible (WCAG 2.4.7, 2.4.11)
Keyboard users need to see where focus is. Never write outline: none without a replacement. Style focus with :focus-visible, which shows only for keyboard focus, not mouse clicks:
:focus-visible {
outline: 3px solid #2d5bd7;
outline-offset: 2px;
}Layout can also hide focus. WCAG 2.2’s Focus Not Obscured (2.4.11) requires that the focused element isn’t entirely hidden by your own content — the usual culprit is a sticky header or footer covering the element that’s scrolled into view. scroll-padding fixes it:
html { scroll-padding-block-start: 5rem; } /* the height of the sticky header */overflow: hidden on a parent can also clip focus outlines; outline-offset and some padding on the parent keep them visible.
6. Orientation (WCAG 1.3.4)
Don’t lock your layout to portrait or landscape. People with mounted devices (on a wheelchair, for example) can’t rotate them. Make sure your layout works in both, including short landscape screens — use height queries to un-stick headers when vertical space is tight.
7. Forced colours and high contrast
In Windows’ contrast themes, the browser replaces your colours with the user’s chosen palette. Background colours and box shadows disappear, so layouts that separate areas only with background colours become a single flat surface.
.card {
background: #f7f7f5;
border: 1px solid transparent; /* invisible normally, drawn in forced-colors mode */
}Test it in DevTools’ rendering panel: Emulate CSS media feature forced-colors: active.
8. Reading order and motion
Covered in earlier lessons, but they belong on this checklist too:
- Keep the DOM order logical (Source order and reading order).
- Respect
prefers-reduced-motionfor layout animations, smooth scrolling and parallax (Media queries).
A layout accessibility checklist
- Works at 320px wide / 400% zoom without sideways scrolling
- Text resizes to 200% via browser settings (sizes in
rem) - No text clipped with the text-spacing overrides
- Targets at least 24px, ideally 44px, with gaps
- Visible focus, never hidden behind sticky elements
- Works in portrait and landscape
- Boundaries visible in forced-colors mode
- DOM order matches the visual order
- Motion respects
prefers-reduced-motion
The pattern behind all of these: avoid fixed sizes and clipping. Let content wrap and grow, and the layout will adapt to whatever people need.
Pass the reflow and text-spacing tests
The starter .promo banner breaks for many users: it has a fixed height, a fixed pixel width, white-space: nowrap and overflow: hidden, so text gets cut off when people zoom or increase text spacing. Fix it so that: at 320px wide nothing scrolls sideways and the layout is one column; with the WCAG text-spacing overrides (line-height 1.5, letter-spacing 0.12em, word-spacing 0.16em, paragraph spacing 2em) no text is clipped; the button keeps a visible focus style and is at least 44px tall.
<section class="promo">
<div class="promo-text">
<h2>Learn CSS layout this month</h2>
<p>Build real layouts with flexbox, grid and container queries, then ship a complete responsive page.</p>
</div>
<a class="promo-button" href="#">Start learning</a>
</section>
<style>
* { box-sizing: border-box; }
.promo {
width: 900px;
height: 120px;
overflow: hidden;
display: flex;
align-items: center;
gap: 24px;
padding: 0 24px;
background: #eaf0fc;
}
.promo-text h2, .promo-text p { margin: 0; white-space: nowrap; }
.promo-button { padding: 4px 12px; background: #2d5bd7; color: white; outline: none; }
</style><section class="promo">
<div class="promo-text">
<h2>Learn CSS layout this month</h2>
<p>Build real layouts with flexbox, grid and container queries, then ship a complete responsive page.</p>
</div>
<a class="promo-button" href="#">Start learning</a>
</section>
<style>
* { box-sizing: border-box; }
.promo {
max-inline-size: 56rem; /* no fixed width */
min-block-size: 7.5rem; /* a minimum, not a fixed height */
display: flex;
flex-wrap: wrap; /* the button drops below when needed */
align-items: center;
gap: 1rem 1.5rem;
padding: 1.5rem;
background: #eaf0fc;
}
.promo-text {
flex: 1 1 20rem;
min-inline-size: min(20rem, 100%);
}
.promo-text h2, .promo-text p { margin: 0; } /* text wraps normally */
.promo-text p { margin-block-start: 0.5rem; }
.promo-button {
display: inline-flex;
align-items: center;
min-block-size: 44px;
padding: 0.5rem 1rem;
background: #2d5bd7;
color: white;
}
.promo-button:focus-visible {
outline: 3px solid #16181d;
outline-offset: 3px;
}
</style>Summary
- WCAG reflow: content must work at 320 CSS pixels wide — what a 1280px screen shows at 400% zoom — without scrolling in two directions.
- Avoid fixed heights, fixed widths,
nowrapandoverflow: hiddenon text containers; they clip content when text grows. - Layouts must survive user text-spacing changes: line-height 1.5, letter-spacing 0.12em, word-spacing 0.16em, paragraph spacing 2em.
- Size with
remso layouts respond to the user’s font size, and keep targets at least 24px (44px is better). - Never remove focus outlines without a replacement, and keep borders so layouts survive forced-colors mode.