---
name: ensuring-accessibility
description: Audits and fixes web UI for WCAG 2.2 AA compliance — keyboard navigation, visible focus, ARIA usage, alt text, form labels, color contrast, target sizes, and reduced motion. Use when the user asks to make a page or component accessible, run an accessibility or a11y audit, fix WCAG violations, add ARIA or alt text, improve keyboard or screen-reader support, or check color contrast. Do not use for general semantic markup structure (structuring-semantic-html) or visual design choices.
---
# Ensuring Accessibility
## When to use / when NOT to use
- **Use for:** auditing or fixing UI against WCAG 2.2 AA — keyboard access, focus, ARIA, alt text, labels, contrast, target sizes, motion preferences.
- **Do NOT use for:** choosing heading/landmark structure for its own sake (structuring-semantic-html), visual design or theming decisions, or backend logic.
## Core rules
1. **Semantic HTML first, ARIA last.** ARIA only when no native element can express the role (first rule of ARIA).
- ✅ ``
- ❌ `
Save
`
2. **Everything interactive works by keyboard alone,** in a logical Tab order, no traps, no drag-only interactions (WCAG 2.5.7).
- ✅ sortable list also offers "Move up/Move down" buttons
- ❌ reorder only via drag-and-drop
3. **Focus must be visible** with ≥3:1 contrast against adjacent colors; never remove it without a replacement.
- ✅ `:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }`
- ❌ `:focus { outline: none; }`
4. **Contrast minimums:** 4.5:1 for normal text, 3:1 for large text (≥24px or ≥18.7px bold) and for UI components/graphics.
5. **Targets ≥24×24 CSS px** (WCAG 2.2), 44×44px for primary touch targets.
6. **Every image has an `alt`:** descriptive for informative images, `alt=""` for decorative ones — never omit the attribute.
- ✅ ``
- ❌ ``
7. **Every form control has a programmatically associated label** (`