Accessibility basics
Accessibility (a11y) means building websites that everyone can use: people who are blind and use screen readers, people who can't use a mouse, people with low vision or colour blindness, people with cognitive disabilities, and anyone on a slow phone in bright sunlight.
Over 1 billion people live with a disability. In many countries accessibility is also a legal requirement. And accessible sites are almost always better for everyone.
How people actually browse
| User | Uses | Needs from you |
|---|---|---|
| Blind | Screen reader (NVDA, VoiceOver, JAWS) | Semantic HTML, alt text, labels, headings |
| Motor impairment | Keyboard only, switch devices, voice control | Everything reachable and usable by keyboard |
| Low vision | Zoom up to 400%, high contrast | Responsive layout, good colour contrast |
| Colour blind | Normal screen | Don't rely on colour alone |
| Deaf / hard of hearing | Captions | Captions and transcripts for media |
Rule 1: semantic HTML first
The first rule of ARIA (see below) is: don't use ARIA if a native HTML element can do the job. Native elements come with keyboard support, focus and roles built in.
Rule 2: every input needs a label
Rule 3: meaningful alt text
| Image | Good alt |
|---|---|
| Product photo | alt="Blue cotton kurta, front view" |
| Chart | alt="Sales doubled from 2023 to 2025": the insight, not "chart" |
| Logo that links home | alt="Learn to Code — home" |
| Decorative swirl | alt="", so screen readers skip it |
| Image containing text | The text itself |
Don't start with "Image of…". Screen readers already announce that it's an image.
Rule 4: headings form an outline
Screen reader users press a key to list or jump between headings, so the headings should read like a table of contents. Use one <h1>, and don't skip levels.
Rule 5: keyboard access and visible focus
Everything interactive must work with Tab, Shift+Tab, Enter, Space, Escape and the arrow keys, and users must be able to see where focus is.
Skip links
Let keyboard users skip the navigation and go straight to the content:
<a class="skip-link" href="#main">Skip to content</a>
…
<main id="main">…</main>Rule 6: colour and contrast
- Normal text needs a contrast ratio of at least 4.5:1 against its background; large text needs 3:1 (WCAG AA).
- Never use colour alone to convey meaning:
ARIA: a last resort
ARIA (Accessible Rich Internet Applications) attributes add accessibility information when HTML alone can't express it, typically for custom widgets.
| Attribute | Example use |
|---|---|
aria-label |
Name for an icon-only button |
aria-describedby |
Link an input to its hint or error text |
aria-expanded |
Is this menu or accordion open? |
aria-live="polite" |
Announce dynamic updates ("3 results found") |
aria-hidden="true" |
Hide decorative content from screen readers |
role="alert" |
Urgent messages announced immediately |
No ARIA is better than bad ARIA. Studies of the top million home pages find that pages using ARIA have more accessibility errors on average. Prefer native elements.
Testing accessibility
- Unplug your mouse. Can you do everything with the keyboard alone?
- Run Lighthouse (Chrome DevTools → Lighthouse) or the axe DevTools extension.
- Try a screen reader: VoiceOver (Cmd+F5 on a Mac) or NVDA (free, on Windows).
- Zoom to 200% and 400%: does anything break or overlap?
Practice
Fix every accessibility problem in this snippet (there are at least 5):
1.What should a purely decorative image have?
2.What's the first rule of ARIA?