Home › Accessibility › Web accessibility (WCAG 2.2) rules

Web accessibility (WCAG 2.2) rules

Windsurf rules for building accessible web UIs to WCAG 2.2 AA: semantics, keyboard, focus, contrast, and testing.

WindsurfAccessibility

How to use

Save this as .windsurf/rules/accessibility.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

.windsurf/rules/accessibility.mdDownload  
# Accessibility (WCAG 2.2 AA)

## Semantics first
- Use native elements: `<button>` for actions, `<a href>` for navigation, `<label for>` for inputs, headings in order (one `<h1>` per page), landmarks (`<header>`, `<nav>`, `<main>`, `<footer>`).
- ARIA only when no native element fits; then follow the APG pattern exactly. No `role="button"` on a `<div>` when a `<button>` works.
- Every image has `alt` (empty `alt=""` for decorative). Icon-only buttons get an `aria-label`.

## Keyboard and focus
- Everything works with keyboard only: Tab order follows visual order, no `tabindex` > 0.
- Visible focus indicator on all interactive elements; never `outline: none` without a replacement.
- Dialogs trap focus, close on Esc, and return focus to the trigger (use `<dialog>` or the UI library's accessible dialog).
- Targets are at least 24x24 CSS px.

## Forms
- Errors are announced (`aria-describedby` to the message, `aria-invalid="true"`), not shown by color alone.
- Use `autocomplete` attributes for personal data fields.

## Visual
- Text contrast >= 4.5:1 (3:1 for large text and UI components). Support 200% zoom and reflow at 320px width.
- Respect `prefers-reduced-motion`.

## Dynamic content
Announce async updates with a polite live region (`aria-live="polite"`).

## Check
Run axe (`@axe-core/playwright` or the browser extension) on changed pages with zero violations, and tab through the flow once.

Related rules

Django Windsurf rules

Windsurf rules for Django 5.2 LTS projects: apps, models and migrations, ORM performance, forms, and tests.

WindsurfDjango

Documentation writing rules

Windsurf rules for writing and updating READMEs, docstrings, ADRs, and changelogs alongside code changes.

WindsurfAgent workflows

Electron app Windsurf rules

Windsurf rules for secure Electron 44 apps: context isolation, preload bridges, typed IPC, and packaging.

WindsurfElectron

FastAPI Windsurf rules

Windsurf rules for FastAPI apps with Pydantic v2, SQLAlchemy 2.0 async, dependency injection, and pytest.

WindsurfPython / FastAPI

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.