Explain it simply
Explain it simply
A building with only stairs keeps out wheelchair users, parents pushing prams and anyone with an injured leg. Add a ramp and everyone gets in. Web accessibility is adding those ramps to a website.
People who listen to the web through a screen reader, who use only a keyboard because they cannot use a mouse, who zoom text to 200%, or who read a phone in bright sunlight are all your users. Writing HTML correctly gives you most of those ramps automatically.
Problem → Why → Solution
The problem: a perfect automated score on an unusable page
A team runs a tool such as Lighthouse and gets a full accessibility score. Yet the code below has three problems that tools usually miss. The chart has an alt attribute, but it is just the file name, so blind users learn nothing. The focus outline is removed, so keyboard users cannot see where they are. Required fields are marked by red colour alone.
<style>
button:focus { outline: none; } /* keyboard users lose track of focus */
.required { color: red; }
</style>
<img src="sales-q2-final.png" alt="sales-q2-final.png">
<label for="email" class="required">Email</label>
<input id="email" name="email" type="email">
<button type="button">Download report</button>Why didn't the tool catch it?
Automated tools can only answer questions a machine can decide, such as "is there an alt attribute?" or "is the label connected?". Whether the alt text means anything, whether focus is visible, and whether the page makes sense without colour need a human judgement. A tool score is a starting point; it never replaces trying the page yourself with a keyboard and a screen reader.
Core concept: POUR and the HTML foundations
The W3C's Web Content Accessibility Guidelines (WCAG) express accessibility as testable success criteria. The current version is WCAG 2.2, and most projects and most legal standards target Level AA. Every criterion sits under four principles, remembered as POUR.
| Principle | Meaning | HTML example |
|---|---|---|
| Perceivable | Content reaches at least one sense | alt on images, captions on video |
| Operable | Usable without a mouse too | <button>, <a href>, visible focus |
| Understandable | Readable and predictable | <html lang>, labels, error text |
| Robust | Assistive tech can parse it | Valid HTML, native elements |
How you write alt text depends on the image's purpose. For an informative image such as a chart or photo, write the information it conveys, not the fact that it is a picture: "Sales rose 30% in April". For a purely decorative image use an empty alt="", and screen readers skip it. Leaving the alt attribute out entirely makes some screen readers read the file name instead.
Every control needs an accessible name, which comes from a button's text, an input's label or an image's alt. Declaring the page language, such as <html lang="en">, lets a screen reader use the right pronunciation; a Myanmar page uses lang="my". Each of these costs a line or two of code yet completely changes the experience.
The keyboard is just as fundamental. Everything interactive must be reachable with Tab and usable with Enter or Space, and the focused element must be visible. Text contrast against its background must be at least 4.5:1 for normal text, and information must never rely on colour alone. Use ARIA only where native HTML cannot do the job, such as naming a button whose only content is a "×" icon.
- Perceivable without sight? (P)
- Operable without a mouse? (O)
- Clear and predictable? (U)
- Built from native HTML? (R)
Tools give you a starting point; a keyboard and a screen reader give you the truth.
General pattern
<html lang="language-code">
<img src="informative.png" alt="What the image tells the reader">
<img src="decoration.png" alt="">
<button type="button" aria-label="Action name">icon</button>
<label for="field-id">Visible label</label>
<input id="field-id" name="field">
<style>:focus-visible { outline: 3px solid currentColor; }</style>The page language, alt for both kinds of image, a name for an icon-only button, a labelled field and a visible focus style: five basics every page needs.
Example: an icon button, a chart and a search field
Each of these three elements carefully gives a screen reader user something meaningful to hear. Press Tab as well and watch focus move to the button and then the search box. Notice that none of it needs JavaScript or extra CSS.
<button type="button" aria-label="Close menu">×</button>
<img src="chart.png" alt="Sales increased by 30 percent in April">
<label for="search">Search tutorials</label>
<input id="search" type="search" name="q">Code breakdown
- Icon-only button
<button type="button" aria-label="Close menu">×</button>"×" is clear to the eye, but a screen reader may say "times". aria-label makes the accessible name "Close menu"; with no visible text to use, this is a legitimate place for ARIA.
- Informative alt
alt="Sales increased by 30 percent in April"It states the chart's key fact, so someone who cannot see the image gets the same information. "Chart image" would tell them nothing.
- Label
<label for="search">Search tutorials</label>for="search" matches the input's id, so the box is named "Search tutorials" and clicking the label focuses it.
- Search input
<input id="search" type="search" name="q">type="search" gives it the searchbox role, and some browsers add a clear button once text is typed.
A small "×" button appears, then, if chart.png is missing, a broken-image icon with the alt text "Sales increased by 30 percent in April", and a "Search tutorials" label with a search box. A screen reader announces the button as "Close menu, button".A five-minute manual check
1. Keyboard only
Put the mouse aside and move through the page with Tab and Shift+Tab. Is focus always visible, is the order logical, and is there anywhere you get stuck?
2. 200% zoom
Zoom the browser to 200% and look for text that overlaps, gets cut off or forces horizontal scrolling.
3. Screen reader smoke test
Turn on NVDA (Windows) or VoiceOver (macOS/iOS), look at the heading and landmark lists, and listen to whether buttons and fields have sensible names.
In real projects
Where this shows up in real projects
For government websites, banks and many e-commerce companies, accessibility is a legal requirement; the European Accessibility Act and US ADA cases, for example, commonly point to WCAG AA as the benchmark. Teams therefore check contrast and focus styles in design review and run an automated checker such as axe in CI on every pull request.
Beyond automated checks, people walk through the key user flows, such as sign-up, checkout and search, with a keyboard and a screen reader before each release. Fixing accessibility at the design stage is far cheaper than after launch, so "we'll add accessibility at the end" tends to be the most expensive plan of all.
Accessible pages help everyone: captions help someone watching video on a noisy bus, high-contrast text is easier to read in sunlight, and solid keyboard support makes power users faster. Clear labels and error messages reduce support requests too.
Common mistakes
Common mistakes
1. Removing the focus outline
Writing outline: none without a replacement leaves keyboard users unable to see where they are. If you dislike the outline on mouse clicks, use :focus-visible to show a strong outline for keyboard focus only.
2. Alt text that is a file name or the word "image"
alt="IMG_2041.jpg" or alt="image" satisfies a tool but tells the user nothing. Screen readers already announce that it is an image, so there is no need to start with "Image of..." either.
3. Piling ARIA onto native elements
<button role="button">, or a link with visible text given a different aria-label, adds nothing and can break voice control, where users speak the text they see. Keep the accessible name consistent with the visible text.
Best practices
Best practices
- Set <html lang="..."> on every page; screen readers choose pronunciation from it.
- Use heading levels in outline order without skipping.
- Put automated checks in CI and manual checks on the release checklist.
Mini challenge
Mini challenge: an accessible newsletter card
Write a newsletter sign-up card that applies all five basics from this lesson, then try it with Tab and no mouse.
- <html lang="en"> and an h2 card heading
- A decorative wave image with alt="" and a photo with informative alt text
- An icon-only "×" button that closes the card, named with aria-label
- An email field linked to a label, plus a :focus-visible outline style
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Newsletter</title>
<style>
/* TODO: a clearly visible keyboard focus style */
</style>
</head>
<body>
<!-- TODO: set the page language on <html> -->
<!-- TODO: close button "×" with an accessible name -->
<!-- TODO: decorative wave.svg and an informative team photo -->
<!-- TODO: h2 heading, labelled email field and a subscribe button -->
</body>
</html>Expected: Tab moves a thick outline to the "×" button, the email field and the Subscribe button in order. A screen reader announces "Close newsletter, button", skips the wave image and reads the photo's alt text.
Show hint
Do not drop the decorative image's alt entirely; write it as an empty alt="". :focus-visible applies only to keyboard-style focus.
Show solution
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Newsletter</title>
<style>
:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
</style>
</head>
<body>
<section aria-labelledby="news-title">
<button type="button" aria-label="Close newsletter"
onclick="this.parentElement.hidden = true">×</button>
<img src="wave.svg" alt="">
<h2 id="news-title">Join our HTML newsletter</h2>
<img src="team.jpg" alt="Three tutors laughing around a laptop in our Yangon office">
<form action="/subscribe" method="post">
<label for="news-email">Email address</label>
<input id="news-email" name="email" type="email" autocomplete="email" required>
<button type="submit">Subscribe</button>
</form>
</section>
</body>
</html>Quick quiz 1 / 3
Quick quiz 2 / 3
Quick quiz 3 / 3
What to remember
- WCAG 2.2 Level AA is the usual target, and its criteria sit under the four POUR principles.
- Informative images describe their information; decorative images get alt="".
- Every interactive element must work with the keyboard and show visible focus.
- Use ARIA only where native HTML cannot help, and back up tool scores with manual tests.