Accessibility

Accessibility (often shortened to "a11y") means making pages usable by everyone, including people who are blind, have low vision, are deaf, can't use a mouse, or have cognitive differences. Most of it comes down to writing good, semantic HTML — which is why it belongs in an HTML course.

Who benefits

  • Screen-reader users hear the page read aloud and navigate by headings, landmarks, links and form fields.
  • Keyboard users — including many people with motor disabilities — move with Tab, Enter, Space and arrow keys.
  • People with low vision zoom in, use high-contrast modes, or enlarge text.
  • Deaf and hard-of-hearing people rely on captions and transcripts.
  • Everyone, sometimes: a broken arm, bright sunlight on a screen, a noisy train, a slow connection.

In many countries, accessibility is also a legal requirement — for example under the European Accessibility Act and the ADA in the US. The international standard is WCAG (Web Content Accessibility Guidelines), currently version 2.2.

Semantic HTML does most of the work

Try it yourself
Result

Native elements come with roles, states and keyboard behaviour built in. Try tabbing through the example: you can reach the real button, but not the div.

The essentials checklist

AreaDoLesson
Pagelang on <html>; a unique, descriptive <title>03
StructureOne <h1>, a logical heading outline, landmark elements06, 24
ImagesMeaningful alt; alt="" for decoration12
LinksDescriptive link text, not "click here"10
FormsLabels for every control; fieldsets for groups; helpful errors29, 32
Tables<th> with scope; a <caption>19
MediaCaptions for video, transcripts for audio16
InteractionReal buttons and links; visible focus; everything works by keyboard31
ColourEnough contrast; never colour alone to convey meaning—

Keyboard access and focus

Try it yourself
Result
  • Never remove focus outlines without replacing them with a clearly visible style.
  • A "skip to main content" link lets keyboard users bypass repeated navigation.
  • Keep the DOM order the same as the visual order, so Tab moves predictably.
  • tabindex="0" adds an element to the tab order; tabindex="-1" makes it focusable only by script. Avoid positive values like tabindex="5", which scramble the order.

Colour and contrast

Try it yourself
Result

WCAG asks for a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text and interface parts. Browser developer tools show the ratio when you inspect a colour.

ARIA: when HTML isn't enough

ARIA (Accessible Rich Internet Applications) attributes add accessibility information to elements:

Try it yourself
Result
AttributePurpose
aria-label, aria-labelledbyGive an element an accessible name
aria-describedbyLink extra description, like hints and errors
aria-expanded, aria-controlsState of a toggle and what it controls
aria-live, role="status"/"alert"Announce content that changes dynamically
aria-hidden="true"Hide decorative content from assistive technology
aria-current="page"Mark the current link in navigation
The first rule of ARIA: don't use ARIA if a native HTML element can do the job. ARIA only changes what assistive technology announces — it adds no keyboard behaviour — and incorrect ARIA is worse than none.

Testing accessibility

  1. Unplug your mouse: can you reach and operate everything with the keyboard? Can you always see where focus is?
  2. Zoom to 200%: does the content reflow without sideways scrolling or overlap?
  3. Run an automated checker: Lighthouse and the Accessibility panel in browser dev tools, or extensions like axe DevTools and WAVE. They catch about a third of issues.
  4. Try a screen reader: VoiceOver (built into macOS and iOS), NVDA (free for Windows), TalkBack (Android).

Try it yourself

Find and fix the accessibility problems: a missing alt, an unlabelled input, a vague link and an icon-only button.

Try it yourself
Result