1---2name: accessibility3description: Build WCAG 2.2 AA compliant interfaces with semantic HTML, ARIA, keyboard navigation, focus management, color contrast, and screen reader support. Covers forms, dialogs, tabs, live regions, skip links, alt text, and data tables. Use when implementing accessible UIs, auditing WCAG compliance, fixing screen reader issues, keyboard navigation, focus traps, or troubleshooting "focus outline missing", "aria-label required", "insufficient contrast", "missing alt text", "heading hierarchy".4license: MIT5---6
7# Web Accessibility (WCAG 2.2 AA)
8
9Build for everyone — accessibility is a requirement, not a feature.
10
11## Contrast Ratios (WCAG AA)
12
13| Element | Minimum Ratio |
14| ---------------------------------- | ------------- |
15| Normal text (< 18pt) | 4.5:1 |
16| Large text (>= 18pt or 14pt bold) | 3:1 |
17| UI components and focus indicators | 3:1 |
18
19## WCAG 2.2 New AA Criteria
20
21| Criterion | Requirement |
22| ----------------------------------- | ------------------------------------------------------------------------------------ |
23| Target Size Minimum (2.5.8) | Interactive targets at least 24x24 CSS pixels |
24| Focus Not Obscured Minimum (2.4.11) | Focused element at least partially visible, not hidden by sticky headers or overlays |
25| Focus Appearance (2.4.13) | Focus indicator has minimum area (2px perimeter) and 3:1 contrast change |
26| Dragging Movements (2.5.7) | Provide single-pointer alternative for any drag interaction |
27| Redundant Entry (3.3.7) | Do not require re-entering previously provided information |
28| Consistent Help (3.2.6) | Help mechanisms (chat, phone, FAQ) appear in same relative order across pages |
29| Accessible Authentication (3.3.8) | No cognitive function test for login (allow paste, autofill, or alternatives) |
30
31## Essential Keyboard Patterns
32
33| Key | Action |
34| --------------- | ------------------------------------- |
35| Tab / Shift+Tab | Navigate between focusable elements |
36| Enter / Space | Activate buttons and links |
37| Arrow keys | Navigate within widgets (tabs, menus) |
38| Escape | Close dialogs and menus |
39| Home / End | Jump to first/last item in widget |
40
41## Element Selection
42
43| Need | Element |
44| ---------------------- | --------------------------------- |
45| Navigates to page | `<a href="...">` |
46| Submits form | `<button type="submit">` |
47| Opens dialog | `<button aria-haspopup="dialog">` |
48| Other action | `<button type="button">` |
49| Self-contained article | `<article>` |
50| Navigation links | `<nav>` |
51| Supplementary info | `<aside>` |
52
53## Common ARIA Attributes
54
55| Attribute | Purpose |
56| ---------------------- | -------------------------------------------------- |
57| `aria-label` | Name when no visible label exists |
58| `aria-labelledby` | Reference existing text as label |
59| `aria-describedby` | Additional description (hints, errors) |
60| `aria-live` | Announce dynamic updates (`polite` or `assertive`) |
61| `aria-expanded` | Collapsible/expandable state |
62| `aria-hidden="true"` | Hide decorative elements from screen readers |
63| `aria-invalid` | Mark form fields with errors |
64| `aria-required="true"` | Mark required fields |
65| `aria-busy` | Indicate loading state |
66
67## WCAG 2.2 AA Checklist Summary
68
69| Principle | Key Requirements |
70| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
71| Perceivable | Alt text on images, contrast >= 4.5:1, color not sole indicator, text resizable to 200%, captions on video, `prefers-reduced-motion` support |
72| Operable | Keyboard accessible, visible focus not obscured, focus appearance meets minimum, targets >= 24px, skip links, dragging alternatives |
73| Understandable | `<html lang="en">`, consistent navigation, consistent help placement, form labels, error identification, no redundant entry, accessible auth |
74| Robust | Valid HTML, name/role/value on all UI components, `aria-live` for status messages (SC 4.1.1 Parsing is obsolete in WCAG 2.2) |
75
76## Anti-Patterns
77
78| Anti-Pattern | Fix |
79| ------------------------------------- | ------------------------------------------------- |
80| `<div onClick>` instead of `<button>` | Use semantic HTML elements |
81| `outline: none` without replacement | Use `:focus-visible` with visible outline |
82| Placeholder as label | Use `<label>` element |
83| `tabindex` > 0 | Use DOM order or `tabindex="0"` / `tabindex="-1"` |
84| Color-only state indicators | Add icon and text label |
85| Skipped heading levels | Use sequential h1-h6, style with CSS |
86| `role="button"` on `<button>` | Remove redundant ARIA |
87| `aria-hidden` on interactive elements | Never hide interactive content |
88| Fixed font sizes (px) | Use `rem` units |
89| No focus trap in modal dialogs | Trap focus, close on Escape |
90
91## Common Mistakes
92
93| Mistake | Correct Pattern |
94| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
95| Adding `aria-label` to elements that already have visible text | Use `aria-labelledby` to reference existing visible text instead |
96| Using `aria-live="assertive"` for non-urgent updates | Use `aria-live="polite"` for most dynamic content; reserve `assertive` for errors and alerts |
97| Setting `alt=""` on informative images | Provide descriptive alt text; only use empty alt on purely decorative images |
98| Adding keyboard handlers to non-focusable elements | Use native interactive elements or add `tabindex="0"` plus `role` and key handlers |
99| Testing only with automated tools like axe | Automated scans catch ~30% of issues; always supplement with keyboard-only and screen reader testing |
100
101## Screen Reader and Browser Pairings
102
103| Screen Reader | Browser | Platform |
104| ------------- | ------- | ------------------ |
105| JAWS | Chrome | Windows |
106| NVDA | Chrome | Windows (free) |
107| NVDA | Firefox | Windows (free) |
108| VoiceOver | Safari | macOS / iOS |
109| TalkBack | Chrome | Android |
110| Narrator | Edge | Windows (built-in) |
111
112## Testing Quick Guide
113
114| Method | Tool | Effort |
115| -------------- | --------------------------------------- | ------- |
116| Keyboard-only | Hide mouse, Tab through page | 5 min |
117| Screen reader | JAWS + Chrome or NVDA + Chrome/Firefox | 10 min |
118| Screen reader | VoiceOver + Safari (macOS) | 10 min |
119| Automated scan | axe DevTools browser extension | 2 min |
120| Lighthouse | Chrome F12 > Lighthouse > Accessibility | 2 min |
121| Unit tests | jest-axe (Jest) or vitest-axe (Vitest) | Ongoing |
122
123## Delegation
124
125When working on accessibility, delegate to:
126
127- `design-system` — Color tokens and contrast verification
128- `react-patterns` — Component patterns and hooks
129- `testing` — jest-axe integration and test patterns
130
131## Resources
132
133- [WCAG 2.2 Quick Reference](https://www.w3.org/WAI/WCAG22/quickref/)
134- [ARIA Authoring Practices Guide](https://www.w3.org/WAI/ARIA/apg/)
135- [MDN Accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility)
136- [WebAIM](https://webaim.org/)
137- [The A11y Project](https://www.a11yproject.com/)
138
139## References
140
141- [Semantic HTML and Structure](references/semantic-html.md) — Document landmarks, heading hierarchy, element selection, skip links
142- [Focus Management](references/focus-management.md) — Focus indicators, focus not obscured, dialog focus traps, SPA route focus, focus-visible patterns
143- [ARIA Patterns](references/aria-patterns.md) — Accessible tabs, live regions, data tables with ARIA attributes
144- [Forms and Validation](references/forms-validation.md) — Label association, error announcement, redundant entry, accessible authentication
145- [Color and Media](references/color-and-media.md) — Contrast requirements, reduced motion, dragging alternatives, video captions, alt text
146- [Testing](references/testing.md) — Keyboard testing, screen reader pairings, axe DevTools, jest-axe and vitest-axe unit tests