Accessibility
Building for everyone — disabilities and assistive technologies, WCAG and the POUR principles, semantic HTML first, keyboard access and focus management, ARIA roles and states, accessible forms, colour contrast, motion, and testing with tools and screen readers.
Accessibility (a11y) means people with disabilities can perceive, understand, navigate and interact with your product. Over a billion people live with some disability — and accessible design also helps people with temporary injuries, situational limits (bright sunlight, a baby in one arm), slow connections and older users. In many places it's a legal requirement (ADA, the European Accessibility Act, India's RPwD Act).
| Disability | Examples | Relies on |
|---|---|---|
| Visual | Blindness, low vision, colour blindness | Screen readers (NVDA, JAWS, VoiceOver, TalkBack), zoom, high contrast |
| Motor | Tremor, paralysis, RSI | Keyboard, switch devices, voice control, eye tracking |
| Auditory | Deaf, hard of hearing | Captions, transcripts |
| Cognitive | Dyslexia, ADHD, memory impairments | Clear language, consistent layouts, no time pressure |
WCAG and POUR
The Web Content Accessibility Guidelines (WCAG 2.2) define testable success criteria at levels A, AA (the usual legal target) and AAA, organised under four principles:
| Principle | Meaning | Examples |
|---|---|---|
| Perceivable | Users can sense the content | Alt text, captions, contrast, text resizes to 200% |
| Operable | Users can operate the interface | Keyboard access, no keyboard traps, enough time, no seizure-inducing flashes, target size |
| Understandable | Content and UI are understandable | Clear labels and errors, predictable navigation, page language |
| Robust | Works with assistive technologies | Valid semantics, correct names, roles and states |
Semantic HTML first
The single most effective technique: use the right native element. It brings keyboard support, focus, roles and states for free (HTML).
<!-- ✗ inaccessible: not focusable, no role, no keyboard activation -->
<div class="btn" onclick="save()">Save</div>
<!-- ✓ -->
<button type="button" onclick="save()">Save</button>- Headings in a logical order (
h1→h2→h3); screen-reader users navigate by them. - Landmarks:
header,nav,main,aside,footer. - Lists for lists, tables (with
thandscope) for tabular data — not for layout. - Links (
a href) navigate; buttons perform actions. - Set the page language:
<html lang="en">.
Text alternatives
<img src="chart.png" alt="Revenue grew from ₹2 crore in 2024 to ₹3.5 crore in 2025">
<img src="divider.svg" alt=""> <!-- decorative: skipped -->
<button aria-label="Close dialog"><svg aria-hidden="true">…</svg></button> <!-- icon-only -->Good alt text conveys the image's purpose in context, not "image of…". Videos need captions; audio needs transcripts.
Keyboard access and focus
Everything must work with a keyboard alone: Tab/Shift+Tab to move, Enter/Space to activate, arrow keys within composite widgets, Escape to close.
- Visible focus indicator: never
outline: nonewithout a replacement. Use:focus-visible:
:focus-visible { outline: 3px solid #4f46e5; outline-offset: 2px; }- Logical tab order follows the DOM order; avoid positive
tabindex.tabindex="0"makes a custom element focusable;tabindex="-1"makes it focusable by script only. - Skip link to jump past navigation:
<a href="#main" class="skip-link">Skip to content</a>. - Focus management in dynamic UIs: when a dialog opens, move focus into it and trap it there; on close, return focus to the trigger. After client-side navigation, move focus to the new page's heading. The native
<dialog>element withshowModal()handles much of this.
ARIA
ARIA (Accessible Rich Internet Applications) attributes add or change semantics for assistive technology when native HTML can't express a widget (tabs, comboboxes, tree views):
| Attribute kind | Examples |
|---|---|
| Roles | role="tablist", role="tab", role="dialog", role="alert" |
| States | aria-expanded, aria-selected, aria-checked, aria-disabled, aria-current="page" |
| Properties | aria-label, aria-labelledby, aria-describedby, aria-controls |
| Live regions | aria-live="polite" / role="status" announce dynamic updates |
<button aria-expanded="false" aria-controls="faq-1">What is CSverse?</button>
<div id="faq-1" hidden>A free computer-science handbook.</div>
<div role="status" aria-live="polite">3 results found</div> <!-- announced when text changes -->Accessible forms
<label for="email">Email address</label>
<input id="email" type="email" autocomplete="email" required
aria-invalid="true" aria-describedby="email-error">
<p id="email-error">Enter an email like name@example.com</p>- Every control has a visible, programmatically associated label (placeholders are not labels).
- Group related controls with
fieldsetandlegend. - Errors: describe what's wrong and how to fix it, associate them with the field, and move focus to an error summary on submit.
- Don't rely on colour alone ("fields in red are required").
- Use
autocompletetokens so browsers and password managers can fill fields.
Colour, contrast and visual design
- Contrast (AA): at least 4.5:1 for normal text, 3:1 for large text (≥ 24px, or ≥ 18.66px bold) and for UI components and focus indicators.
- Never use colour as the only means of conveying information — add text, icons or patterns (charts, form errors, status badges).
- Support zoom to 200% and reflow at 320px width without horizontal scrolling; size text in
rem. - Touch targets at least 24×24 px (WCAG 2.2 AA), ideally 44×44.
- Respect
prefers-reduced-motion; avoid flashing more than 3 times per second; let users pause auto-playing carousels and video.
Testing
| Method | Catches |
|---|---|
| Automated: axe DevTools, Lighthouse, eslint-plugin-jsx-a11y, Playwright + axe in CI | ~30–40% of issues: missing alt, contrast, missing labels, invalid ARIA |
| Keyboard-only walkthrough | Unreachable controls, traps, invisible focus, illogical order |
| Screen reader testing (VoiceOver, NVDA) | Unlabelled controls, confusing announcements, missing live updates |
| Zoom to 200–400%, high-contrast mode | Overlapping and cut-off content |
| Testing with disabled users | Real-world usability problems |
Automated tools can't judge whether alt text is meaningful or whether a flow makes sense — manual testing is essential.
- Accessibility serves people with visual, motor, auditory and cognitive disabilities — and everyone else.
- WCAG 2.2 AA is the usual target; principles are Perceivable, Operable, Understandable, Robust.
- Semantic HTML gives roles, focus and keyboard behaviour for free; use ARIA only when native elements can't.
- Ensure full keyboard access, visible focus, skip links, and focus management for dialogs and route changes.
- Label every form control; announce errors; meet contrast ratios; don't rely on colour alone; respect reduced motion.
- Combine automated checks with keyboard and screen-reader testing.