Accessibility and Responsive Design
Accessibility (a11y) lets keyboard users, screen reader users, and people with low vision or color-vision deficiencies use the product; responsive design makes the same interface work from phones to large screens. Neither is a patch before launch; both are default requirements of design and components.
Core concepts
| Concept | Meaning |
|---|---|
| WCAG 2.2 | W3C's Web Content Accessibility Guidelines, a W3C Recommendation since 2023-10. Levels A / AA / AAA; products usually target AA |
| POUR | Perceivable, Operable, Understandable, Robust |
| Accessibility tree | The structure the browser builds from the DOM and ARIA and exposes to screen readers: role, name, state |
| ARIA | Attributes (role, aria-*) that add semantics to the accessibility tree. Prefer native HTML elements when they can express it; wrong ARIA is worse than none |
| Live region | A region whose changes screen readers announce automatically; suits live status |
| Responsive | Layout adapts to the viewport (media queries) or the container (container queries) |
How it works
1. The WCAG 2.2 AA criteria that matter most in products
| Criterion | Requirement | Typical problem in tool UIs |
|---|---|---|
| 1.4.1 Use of Color | Don't convey information by color alone | Status shown only by red/green dots |
| 1.4.3 Contrast (Minimum) | Body text contrast ≥ 4.5:1, large text ≥ 3:1 | Light gray secondary text |
| 1.4.11 Non-text Contrast | UI components and graphics ≥ 3:1 against adjacent colors | Input borders or chart lines too faint |
| 1.4.10 Reflow | Readable at 320 CSS px wide without horizontal scrolling (data tables and similar are exceptions) | Fixed-width layouts |
| 2.1.1 Keyboard | All functionality works from the keyboard | Drag-only actions, buttons that appear only on hover |
| 2.4.7 Focus Visible | Keyboard focus is visible | outline: none removed the focus ring |
| 2.4.11 Focus Not Obscured (Minimum) (new in 2.2) | A focused element isn't entirely hidden | Sticky footers or overlays covering the focused element |
| 2.5.7 Dragging Movements (new in 2.2) | Dragging has a single-pointer alternative | Drag-only reordering |
| 2.5.8 Target Size (Minimum) (new in 2.2) | Targets at least 24×24 CSS px (with exceptions such as spacing) | Tiny icon buttons in dense tables |
| 4.1.3 Status Messages | Status messages are perceivable by screen readers without receiving focus | "Saved" or "Task failed" never heard by screen reader users |
2. Announcing live status
role="status": implicitlyaria-live="polite", announced when the screen reader is idle; good for "Task finished"role="alert": implicitlyaria-live="assertive", interrupts immediately; use only for urgent errors- The live region container should already exist on the page before its content changes, otherwise announcements are unreliable
- Don't put high-frequency changes (logs, token streams) in a live region, or the screen reader will talk nonstop. Announce only key state changes
html
<!-- Present from page load; announced when its content changes -->
<div role="status" class="sr-only" id="task-announcer"></div>3. Focus management
| Situation | What to do |
|---|---|
| Opening a dialog | Move focus into it; content outside can't be interacted with. Native <dialog> with showModal() handles focus containment and Esc to close |
| Closing a dialog / drawer | Return focus to the button that opened it |
| Route change (SPA) | Move focus to the new page heading or main content, and update document.title |
| New rows inserted live | Don't steal the user's current focus |
| "Handle it" jump | Open the form and focus its first field |
4. Responsive: viewport vs container
- Media queries adjust the overall layout by viewport width (e.g. side-by-side panes become stacked on phones)
- Container queries let a component adapt to the width of its own container. The same "task card" switches layout automatically in a narrow sidebar vs. a wide main area, which makes components reusable
- Dense tables on phones: keep the 2–3 most important columns plus status and move the rest to the detail view, or switch to a card list. Data tables may scroll horizontally (Reflow has an exception for them), but key actions must not be hidden off-screen
css
.task-card-wrap { container-type: inline-size; }
@container (min-width: 480px) {
.task-card { display: grid; grid-template-columns: auto 1fr auto; }
}In practice
Developer checklist
- [ ] The main flow works with only
Tab/Shift+Tab/Enter/Space/Esc/ arrow keys - [ ] The focus ring is clearly visible and not covered by sticky bars
- [ ] Every state has text or an icon, not just color
- [ ] Icon buttons have accessible names (
aria-labelor visually hidden text) - [ ] Form errors are linked to their inputs (
aria-describedby) and explained in text - [ ] Key state changes are announced via
role="status" - [ ] The main flow works at 320–375px wide
- [ ]
prefers-reduced-motionis respected (see Design systems, component abstraction and motion)
How to test
| Method | Finds | Limits |
|---|---|---|
axe (browser extension, @axe-core/playwright) | Automatically detectable issues: contrast, missing labels, wrong ARIA | Automation finds only part of the problems; Playwright's docs also say it must be combined with manual assessment |
| Lighthouse accessibility score | A quick overview | A high score doesn't mean usable |
| Keyboard walkthrough | Focus order, keyboard traps, unreachable features | Manual |
| Screen readers (macOS VoiceOver, Windows NVDA) | Whether names, roles and announcements make sense | Requires learning the basics |
Common pitfalls
- A
divas a button: no keyboard support and no role. Use<button>, or addrole,tabindexand key handlers (not recommended). outline: nonewith no replacement focus style. Use:focus-visibleto show focus rings only for keyboard use.- ARIA overuse: redundant roles on native elements, or
aria-hidden="true"on focusable elements. - Creating a live region and writing to it immediately: some screen readers won't announce it.
- Small screens just shrink everything: text and targets get too small and tables collapse.
- Testing only in desktop Chrome: check at least once in Safari on iOS.
Common interview questions
- Which AA criteria did WCAG 2.2 add compared with 2.1?
- How do screen reader users perceive live task status? What's the difference between
role="status"androle="alert"? - How should focus be handled when a dialog opens and closes?
- When do you use media queries vs. container queries?
- How do you handle dense tables on phones?
- Can automated accessibility testing replace manual testing?
Related projects
- Agent Run Console: accessibility and the 375px small-screen layout in D14–15; key states announced via
role="status"; status labels carry both an icon and text. - This site: already responsive with light and dark themes; run the checklist above with axe and a keyboard walkthrough and fix what turns up.
Sources
- W3C: What's New in WCAG 2.2
- W3C: WCAG 2.2
- W3C: Understanding SC 2.5.8 Target Size (Minimum)
- W3C: Understanding SC 4.1.3 Status Messages
- WAI-ARIA Authoring Practices Guide — keyboard conventions for Dialog, Grid and other components
- MDN: ARIA live regions
- MDN: The
<dialog>element - MDN: CSS container queries
- Playwright: Accessibility testing — using
@axe-core/playwrightand the limits of automation
