---
name: accessibility
description: Use when building or reviewing UI components to ensure WCAG 2.1 compliance, keyboard navigation, semantic HTML, ARIA attributes, color contrast, and assistive technology support.
---
# UI Accessibility (WCAG 2.1)
## Overview
This skill guides implementation and review of accessible UI components following **WCAG 2.1 Level AA standards**. Accessibility ensures your interface is usable by everyone—keyboard users, screen reader users, users with low vision, and users with cognitive disabilities.
**Core principle:** Semantic HTML first, ARIA last. Keyboard navigation and screen reader support are non-negotiable.
---
## When to Use / When NOT to Use
### ✅ Use This Skill When
- Building new UI components (buttons, modals, dropdowns, forms, tabs)
- Adding keyboard navigation or focus management
- Reviewing code for accessibility violations
- Testing with screen readers or keyboard-only
- Ensuring color contrast and visual focus indicators
- Adding ARIA attributes to dynamic content
### ❌ Do NOT Use When
- Component is purely decorative (no interaction needed)
- Audience explicitly doesn't include users with accessibility needs (internally impossible—always assume diverse users)
- You're skipping automated testing due to time constraints (violates DoD)
---
## Core Concepts
### 1. Semantic HTML Structure
**Foundation:** Use meaningful HTML elements to convey structure and purpose.
```html
Page Title
Section Heading
Content...
Main Title
Section
Subsection
Another Section
Home
About
Page Title
Main Title
Jumps to h3 (breaks hierarchy)
```
**Label Association Rules:**
```html
```
---
### 2. Keyboard Navigation
**Principle:** All interactive features usable via keyboard—Tab, Shift+Tab, Enter, Space, Arrow keys, Escape.
**Key Bindings:**
- **Tab / Shift+Tab**: Move focus forward/backward
- **Enter / Space**: Activate buttons, toggle checkboxes
- **Arrow keys**: Navigate lists, menus, sliders, tabs (up/down for vertical; left/right for horizontal)
- **Home / End**: Jump to first/last item in list
- **Escape**: Close modal, dropdown, or menu
**Focus Management:**
```html
Skip to main content
button:focus {
outline: none; /* NEVER DO THIS */
}
```
**Skip Links (Focus Management):**
```html
Skip to main content
```
---
### 3. ARIA Attributes
**Golden Rule:** Semantic HTML first. Use ARIA only when native HTML doesn't exist or to enhance semantics.
#### Common ARIA Attributes
| Attribute | Purpose | Example |
|-----------|---------|---------|
| `aria-label` | Names element (for icons, buttons without text) | `` |
| `aria-labelledby` | Links to another element as label | `