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.

Intermediate 5 min readLesson 14 of 14

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).

DisabilityExamplesRelies on
VisualBlindness, low vision, colour blindnessScreen readers (NVDA, JAWS, VoiceOver, TalkBack), zoom, high contrast
MotorTremor, paralysis, RSIKeyboard, switch devices, voice control, eye tracking
AuditoryDeaf, hard of hearingCaptions, transcripts
CognitiveDyslexia, ADHD, memory impairmentsClear 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:

PrincipleMeaningExamples
PerceivableUsers can sense the contentAlt text, captions, contrast, text resizes to 200%
OperableUsers can operate the interfaceKeyboard access, no keyboard traps, enough time, no seizure-inducing flashes, target size
UnderstandableContent and UI are understandableClear labels and errors, predictable navigation, page language
RobustWorks with assistive technologiesValid 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).

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 th and scope) for tabular data — not for layout.
  • Links (a href) navigate; buttons perform actions.
  • Set the page language: <html lang="en">.

Text alternatives

HTML
<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: none without a replacement. Use :focus-visible:
CSS
: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 with showModal() 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 kindExamples
Rolesrole="tablist", role="tab", role="dialog", role="alert"
Statesaria-expanded, aria-selected, aria-checked, aria-disabled, aria-current="page"
Propertiesaria-label, aria-labelledby, aria-describedby, aria-controls
Live regionsaria-live="polite" / role="status" announce dynamic updates
HTML
<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

HTML
<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 fieldset and legend.
  • 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 autocomplete tokens 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

MethodCatches
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 walkthroughUnreachable controls, traps, invisible focus, illogical order
Screen reader testing (VoiceOver, NVDA)Unlabelled controls, confusing announcements, missing live updates
Zoom to 200–400%, high-contrast modeOverlapping and cut-off content
Testing with disabled usersReal-world usability problems

Automated tools can't judge whether alt text is meaningful or whether a flow makes sense — manual testing is essential.

Key takeaways
  • 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.