HTML & CSS
Accessibility Is a Layout Constraint, Not a Checklist
Focus obscuring, 24px targets, reduced motion, 200% zoom. The WCAG 2.2 rules that change the layout, not the audit.
Accessibility is usually filed under compliance, which is why it gets audited once and forgotten. It is more useful to treat it as a layout constraint: a set of facts about human bodies and input devices that your layout has to survive, exactly like a narrow viewport.
The constraints that change layout
- Target size. WCAG 2.2 requires a minimum 24×24 CSS px target (with exceptions for inline links and spacing). A row of icon buttons at 20px is not a style choice, it is a failure.
- Focus not obscured. A sticky header that covers the element you just tabbed to is a 2.4.11 failure. `scroll-margin-top` is the fix.
- Dragging movements. If reordering requires a drag, provide a non-drag path — buttons, a menu, keyboard.
- Text spacing and zoom. At 200% zoom and 1.5 line height, a fixed-height card clips its own content.
- Reduced motion. A parallax hero is a vestibular trigger. `prefers-reduced-motion` is a layout branch, not a polish item.
/* Sticky header: do not let focus hide behind it. */
:root { --chrome: 68px; }
:target, :focus-visible { scroll-margin-top: calc(var(--chrome) + 1rem); }
/* 24px minimum targets for icon-only controls. */
.icon-btn { min-width: 44px; min-height: 44px; }
/* Motion is a preference, not a default. */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}Semantics first, ARIA last
A `<button>` is focusable, activates on Enter and Space, and announces itself as a button. A `<div onClick>` is none of those things. Before adding a role, check whether the element you already used has the semantics you want. Bad ARIA is worse than no ARIA, because it overrides the browser's correct guess with a wrong claim.
The corollary: one `<h1>` per page, headings in order, a `<main>` landmark, and a skip link that actually moves focus. Those four things are most of a screen-reader navigation experience.
Contrast that survives a theme
A palette that passes in light mode can fail in dark mode, because the luminance relationship flips. Test both. Body text at 4.5:1, large text at 3:1, and never encode meaning in colour alone — a red border with no icon or text is invisible to a reader who cannot distinguish it.
:root {
color-scheme: light dark;
--text: light-dark(#111111, #ededed);
--bg: light-dark(#ffffff, #121212);
--accent-text: light-dark(#9a3412, #fdba74); /* both pass 4.5:1 on --bg */
}If the layout only works for a mouse, a 1440px window and perfect vision, it does not work. It is a demo.
A short checklist you can actually finish
- Tab through the whole page. You can see every focus ring and reach every control.
- Zoom to 200%. Nothing clips and nothing overlaps.
- Turn on reduced motion. Nothing essential disappears.
- Run one automated audit for the mechanical failures, then read the page yourself for the rest.