Use the right HTML element
Screen readers announce what an element is. Use a <button> for actions and an <a href> for navigation, instead of a clickable <div>:
<!-- Hard to use: no keyboard focus, not announced as a button -->
<div onclick="save()">Save</div>
<!-- Accessible: focusable, works with Enter and Space -->
<button type="button" onclick="save()">Save</button>
Structure pages with <header>, <nav>, <main> and <footer>, and use headings in order. Many screen-reader users jump between headings to scan a page.
Describe images
- Describe what matters in the image for this page:
alt="Bar chart: test scores rose from 62% to 81%". - For a linked image, describe where the link goes.
- For purely decorative images, use an empty
alt=""so screen readers skip them.
Colour and contrast
Normal text needs a contrast ratio of at least 4.5:1 with its background (3:1 for large text), the WCAG AA level. Light grey text on white often fails. Also never use colour alone to carry meaning: add text or an icon to a red error border, so people with colour blindness get the message too.
Keyboard and focus
Put your mouse away and press Tab through your page. You should be able to reach and use every link, button and field, in a sensible order, and always see where you are. Never remove focus outlines without a replacement:
:focus-visible {
outline: 3px solid #2f8a74;
outline-offset: 2px;
}Forms, links and motion
- Give every input a visible label (see HTML forms).
- Write link text that makes sense alone: "Read the SQL tutorial", not "click here".
- Respect people who are sensitive to movement by reducing animation for them:
@media (prefers-reduced-motion: reduce) {
* { animation: none !important; transition: none !important; }
}Try it yourself
Test a page you built in Unays Code with the keyboard only, then run the Lighthouse accessibility check in your browser's developer tools and fix what it reports. If your computer has a built-in screen reader (VoiceOver on Mac, Narrator on Windows), listen to your page once.
This tutorial was written with AI assistance and reviewed by Unays. The runnable code examples were tested before publishing. Spotted a mistake? Tell us at [email protected].