What is accessibility (a11y)?

Accessibility (a11y, "a" + 11 letters + "y") means building websites that everyone can perceive, understand, navigate and interact with, including people who use screen readers, keyboards only, voice control, magnification, or who have color blindness, cognitive or motor disabilities. The standard is WCAG (Web Content Accessibility Guidelines), currently 2.2, with level AA as the usual legal target.

The four WCAG principles (POUR)

  • Perceivable: text alternatives (alt), captions, sufficient color contrast (4.5:1 for body text).
  • Operable: everything works with a keyboard, visible focus, no keyboard traps, enough time.
  • Understandable: clear labels, predictable behavior, helpful error messages.
  • Robust: valid, semantic markup that assistive technologies can interpret.

High-impact practices

  • Use semantic HTML first: <button>, <a href>, <label>, headings in order, landmarks.
  • Every form control has a visible <label>.
  • Do not convey information by color alone.
  • Keep a visible :focus-visible outline.
  • Respect prefers-reduced-motion.
  • Add a "Skip to content" link.

Testing

Automated tools (axe, Lighthouse) find roughly a third of issues. Also test with a keyboard (Tab, Shift+Tab, Enter, Space, Esc) and a screen reader (VoiceOver, NVDA).

Why it matters

It is a legal requirement in many places (ADA, the European Accessibility Act), it improves SEO and usability for everyone, and roughly 1 in 6 people live with a disability.

Code example

html
1<style>
2 body { font-family: system-ui; }
3 .skip { position: absolute; left: -999px; }
4 .skip:focus { left: 8px; top: 8px; background: #ffd84d; padding: 8px; }
5 :focus-visible { outline: 3px solid #2b4bff; outline-offset: 2px; }
6 .error { color: #b00020; }
7</style>
8<a class="skip" href="#main">Skip to content</a>
9<nav aria-label="Primary"><a href="#">Home</a> · <a href="#">Pricing</a></nav>
10<main id="main">
11 <h1>Create account</h1>
12 <form novalidate>
13 <label for="email">Email</label>
14 <input id="email" type="email" autocomplete="email" required aria-describedby="email-err">
15 <p id="email-err" class="error" aria-live="polite"></p>
16 <button>Sign up</button>
17 </form>
18 <img src="https://picsum.photos/200/80" alt="Team celebrating a product launch" width="200" height="80">
19</main>
20<script>
21 document.querySelector("form").addEventListener("submit", (e) => {
22 e.preventDefault();
23 const input = document.getElementById("email");
24 const msg = input.validity.valid ? "" : "Error: enter a valid email address.";
25 document.getElementById("email-err").textContent = msg; // announced by screen readers
26 input.setAttribute("aria-invalid", String(!input.validity.valid));
27 });
28</script>

Practice this question

Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the HTML & CSS set.

Open in study app