Learn / Compliance / Lesson 19

Accessibility

Alt text, colour contrast and keyboard navigation. Three habits that make a site usable for people with disabilities, and that courts have started to enforce.

Last updated: 2026-09-19

What it is

Accessibility means people can use your site whatever their abilities: with a screen reader, with low vision, with only a keyboard, with shaking hands. The shared standard is the Web Content Accessibility Guidelines (WCAG) 2.2, and level AA is the usual target.

Why it is a rule

How to do it

Alt text

Every image gets an alt.

html
<img src="chart.png" alt="Sales rose from 1.2M in Q1 to 1.9M in Q2">
<img src="swirl.svg" alt="">
<button aria-label="Close"><i class="icon-x"></i></button>

Contrast

WhatMinimum ratio
Body text4.5 : 1
Large text (24 px, or 18.66 px bold)3 : 1
Input borders, focus rings, meaningful icons3 : 1

Check both light and dark themes. Measure the worst spot, such as text over a gradient or a moving background, not the average. And never use colour as the only signal: a red cell also needs an icon or text.

Keyboard

css
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none; transition: none; } }

Use real elements

A <button> is focusable, clickable with the keyboard and announced as a button, for free. A <div onclick> is none of those until you rebuild all of it by hand.

How we do it here

Our public screens are checked against a contrast gate in both themes. Animated backgrounds are hidden from assistive technology and slow down or stop for people who prefer reduced motion. Lessons like this one keep a visible focus ring on every link.

Benefits

Disadvantages

Checklist

Sources

Read this lesson as Markdown