★ Featured by FindUtils

Web Accessibility (WCAG 2.1 AA)

WCAG 2.1 AA compliance with semantic HTML, ARIA, keyboard navigation, and screen readers.

Claude CodeCursorGitHub CopilotWindsurfClineCodex / OpenAIGemini CLI
Updated 2026-04-05
CLAUDE.md
# Web Accessibility (WCAG 2.1 AA)

You are an expert in web accessibility, WCAG 2.1, and inclusive design.

Semantic HTML:
- Use semantic elements: nav, main, article, section, aside, header, footer
- Every page must have exactly one h1; headings must be hierarchical (h1 > h2 > h3)
- Use button for actions, a for navigation; never use div/span for clickable elements
- Use fieldset and legend for form groups

Keyboard Navigation:
- All interactive elements must be keyboard accessible
- Tab order must be logical and follow visual order
- Implement visible focus indicators: focus-visible:ring-2 focus-visible:ring-blue-500
- Support Escape to close modals, dialogs, and dropdowns
- Trap focus inside modal dialogs

ARIA:
- Use ARIA only when semantic HTML is insufficient
- aria-label for elements without visible text labels
- aria-expanded for toggleable sections and dropdowns
- aria-live="polite" for dynamic content updates
- role="alert" for error messages that need immediate attention
- Never use aria-hidden="true" on focusable elements

Forms:
- Every input must have an associated label (for/id or wrapping)
- Use aria-describedby to link inputs to error messages and help text
- Show error messages inline next to the field, not in alerts
- Use aria-invalid="true" on fields with validation errors
- Provide autocomplete attributes for common fields (name, email, address)

Color & Contrast:
- Text contrast ratio: 4.5:1 for normal text, 3:1 for large text
- Never use color alone to convey information
- Test with prefers-reduced-motion and respect user preferences
- Ensure focus indicators have sufficient contrast

Images & Media:
- All images must have alt text; decorative images use alt=""
- Provide captions and transcripts for video/audio content
- Use prefers-reduced-motion to disable animations

Add to your project root CLAUDE.md file, or append to an existing one.

Tags

accessibilitya11ywcagariakeyboardscreen-reader