HTML Accessibility: Building for Everyone
Think of a building with a grand staircase and no ramp. A lot of people can enter easily. But someone using a wheelchair cannot, a parent with a pushchair struggles, and a delivery worker with a heavy trolley is stuck at the bottom. Nobody planned to exclude them. The designer simply did not think about them.
Websites are the same. A page can look beautiful and still lock people out: a button that works only with a mouse, a picture with no description, a form that never says what went wrong. Web accessibility is the practice of building pages so that as many people as possible can use them, whatever their abilities, devices, or circumstances.
The good news: HTML was designed with accessibility in mind. Most of the work is choosing the right element and writing clear content. This section teaches you how.
What You Will Learn in This Sectionβ
- Why accessibility matters, and who it helps
- The four principles of the Web Content Accessibility Guidelines (WCAG)
- How people really use the web: screen readers, keyboards, magnifiers, voice, and switches
- Building with semantic HTML, the foundation of accessible pages
- Writing accessible names, images, links, buttons, forms, and tables
- ARIA: what it is, when to use it, and when not to
- Keyboard use and focus management
- Testing your work
The Big Ideaβ
- HTML Code
- Experience the Page
<main>
<h1>Join The Bread Bin</h1>
<form>
<label for="email">Email address</label>
<input id="email" type="email" autocomplete="email" required>
<button type="submit">Subscribe</button>
</form>
<img src="loaf.jpg" alt="A golden sourdough loaf on a wooden board">
</main>
Join The Bread Bin
Weekly recipes, sent every Friday. Read our story
Green means subscribe. Red means no thanks.
Try the options above, one at a time.
These are rough simulations for building understanding. They are not a medical model of any condition, and no simulation replaces testing with, and listening to, real disabled people.
Try each option, one at a time. Turn on "No mouse" and press Tab. Turn on "Hide the focus outline" and try again. Then switch to a colour-vision option, and look at the two buttons. Small choices in HTML and CSS make a very big difference for real people.
Who Benefits?β
Accessibility is often pictured as helping a small group. In fact, the numbers are large. The World Health Organization estimates that roughly one in six people in the world lives with a significant disability. And everyone is sometimes limited:
| Kind of barrier | Permanent | Temporary | Situational |
|---|---|---|---|
| Seeing | Blindness, low vision, colour blindness | Eye surgery, a lost pair of glasses | Bright sunlight on a phone |
| Hearing | Deafness, hearing loss | An ear infection | A noisy train, or a silent office |
| Movement | Paralysis, tremor, limb difference | A broken arm | Holding a baby in one arm |
| Thinking and learning | Dyslexia, autism, memory differences | A concussion | Tiredness, stress, a second language |
Features built for disabled people often help everyone. Captions help in a noisy cafΓ©. A keyboard-friendly form is faster for power users. Good contrast helps outdoors. Clear writing helps people reading in a second language. This is called the curb-cut effect: ramps cut into pavements for wheelchairs are used by cyclists, parents, and travellers with suitcases every day.
How People Use the Webβ
Not everyone uses a mouse and a screen the way you do. Some of the ways people use the web:
| Tool or method | Who uses it | What it needs from your HTML |
|---|---|---|
| Screen reader | People who are blind or have low vision | Real headings, landmarks, labels, text alternatives |
| Keyboard only | People who cannot use a mouse, and many who prefer not to | Everything reachable and usable with Tab, Enter, Space, and arrows. A visible focus |
| Switch devices and voice control | People with limited movement | Real buttons and links with clear names, so that "click Subscribe" works |
| Screen magnifier or zoom | People with low vision | Layouts that stay usable at 200 percent and more |
| High-contrast or custom colours | People with low vision, light sensitivity, or dyslexia | Do not depend on your own colours alone |
| Captions and transcripts | People who are deaf or hard of hearing, and many others | Text versions of audio and video |
| Reduced motion settings | People with vestibular disorders or motion sensitivity | Respecting prefers-reduced-motion |
| Simple, predictable pages | People with cognitive or learning disabilities | Plain language, consistent layout, clear errors |
The Four Principles: POURβ
The Web Content Accessibility Guidelines, known as WCAG, are the international standard. They are built on four principles, remembered by the word POUR:
| Principle | The question it asks | Example |
|---|---|---|
| Perceivable | Can people sense the content? | Text alternatives for images, captions for video, enough contrast |
| Operable | Can people use the controls? | Everything works with a keyboard, no traps, enough time |
| Understandable | Can people make sense of it? | Clear language, predictable behaviour, helpful error messages |
| Robust | Does it work with many tools, now and later? | Valid, semantic HTML, with names, roles, and states that assistive technology can read |
Sort a few real barriers into the four principles:
- HTML Code
- Sort the Barriers
<!-- Perceivable: a text alternative -->
<img src="chart.png" alt="Sales rose 20 percent in 2026">
<!-- Operable: a real button works with Enter and Space -->
<button type="button">Open menu</button>
<!-- Understandable: an error that says what to do -->
<p id="err" role="alert">Enter an email address, such as name@example.com.</p>
<!-- Robust: a native element, with a role and state built in -->
<input type="checkbox" id="news"> <label for="news">Send me the newsletter</label>
Barrier 1 of 8
A photo of a product has no text alternative.
Which principle does it break?
Many real barriers fit more than one principle. In this drill, pick the one that fits best. You will see all four principles in detail in the lesson on WCAG basics.
WCAG organises its rules into three levels: A (the minimum), AA (the usual target, and the level most laws and policies ask for), and AAA (the highest, and not possible for every kind of content). The current published version is WCAG 2.2, and newer versions may appear, so check the W3C for the latest.
Contrast: Your First Measurable Ruleβ
One accessibility rule is easy to measure: the contrast between text and its background. WCAG asks for at least 4.5 to 1 for normal text at level AA, 3 to 1 for large text, and 3 to 1 for important icons and the borders of form fields. Try the checker below with your own colours:
- HTML Code
- Contrast Checker
/* A light grey on white often fails. This passes at 4.5 to 1 */
body {
background: #ffffff;
color: #595959;
}
/* Never remove the focus outline without replacing it */
:focus-visible {
outline: 3px solid #1d4ed8;
outline-offset: 2px;
}
The quick brown fox jumps over the lazy dog.
Contrast ratio: 4.54 : 1
| Requirement | Needs at least | Result |
|---|---|---|
| AA, normal text | 4.5 : 1 | Pass |
| AAA, normal text | 7 : 1 | Fail |
| AA, icons and input borders (non-text) | 3 : 1 | Pass |
The default grey (#767676 on white) is the lightest grey that just passes for normal text. The ratio uses the formula from the Web Content Accessibility Guidelines. It cannot judge font weight, thin letter shapes, or images behind text, so always look at the real result too.
The First Rule of ARIAβ
You will meet ARIA later in this section. It is a set of attributes that can add accessibility information to elements. It is powerful, but the most important thing to know is its first rule:
If a native HTML element already does the job, use it. A real <button> is already focusable, works with Enter and Space, and tells assistive technology it is a button. A <div role="button"> has none of that until you build it yourself. ARIA changes only what is announced. It does not add behaviour.
What Is in This Sectionβ
ποΈ Introduction to A11y
Learn what web accessibility (a11y) means, why it matters for people, law, business and quality, the common myths, and the one idea that explains everything: the accessibility tree. Includes a live keyboard test of fake and real buttons, a simplified accessibility tree viewer, and a ten-minute self-audit.
ποΈ WCAG Basics
Learn the Web Content Accessibility Guidelines (WCAG): the four principles, the three conformance levels A, AA and AAA, how success criteria work, the rules beginners meet most, and what is new in WCAG 2.2. Includes a searchable success-criteria explorer, a live text-spacing test, and a level drill.
ποΈ Semantic Accessibility
Learn how semantic HTML makes pages accessible: heading outlines, landmarks, lists, buttons versus links, skip links, reading order, and visually hidden text. Includes a live structure navigator that shows what a screen reader user can jump between, and a real skip-link focus test.
ποΈ Screen Readers
Learn what screen readers are, how they turn HTML into speech and braille, which ones people use, what they announce for headings, links, buttons, forms and images, and how to try one yourself. Includes a live reader that speaks a page using your browser's built-in speech, and a drill that matches code to what is announced.
ποΈ Keyboard Accessibility
Learn how to make every part of a web page work with a keyboard: which elements are focusable, how tabindex and focus order work, how to style focus with :focus-visible, how to avoid keyboard traps, and how arrow keys and roving tabindex work in custom widgets. Includes a live focus-order lab, a focus-style test, and a roving toolbar.
ποΈ Focus Management
Learn how to move keyboard focus on purpose: how focus() and document.activeElement work, when to move focus (dialogs, deleted items, form errors, page changes), how to return focus, and how to avoid stealing it. Includes three live labs: a delete-and-lose-focus lab, a dialog focus lab, and a form error summary lab.
ποΈ Accessible Names
Learn what an accessible name is, where browsers get it from (aria-labelledby, aria-label, labels, alt text, content, title), how to write good names, and why the visible label must be part of the name. Includes a live name calculator, a page name audit, and a short drill.
ποΈ Alt Text
Learn how to write good alt text: the five kinds of images (informative, decorative, functional, images of text, complex), how to decide which one you have, how to write short, useful descriptions, and how to handle links, charts, SVG, and figures. Includes a decision guide, an alt text writing practice lab, and a live alt text checker.
ποΈ Accessible Links
Learn how to build links that everyone can understand and use: meaningful link text, links versus buttons, keyboard and focus, visual styling, links that open new tabs, file and email links, and safe external links. Includes a links-list lab, a link builder, and a live link checker.
ποΈ Accessible Buttons
Learn how to build buttons that work for everyone: use the real button element, set the type, name icon buttons, make toggle and disclosure buttons with aria-pressed and aria-expanded, handle disabled and loading states, and avoid fake buttons made from div and span. Includes a toggle lab, a disabled-button lab, and a live button checker.
ποΈ Accessible Forms
Learn how to build forms that everyone can complete: visible labels, fieldset and legend, hints and required fields with aria-describedby, the right input types and autocomplete, clear error messages, sensible validation timing, and safe, accessible sign-in. Includes a live field builder, a validation timing lab, and a form checker.
ποΈ Accessible Tables
Learn how to build data tables that work for screen reader and keyboard users: when to use a table, captions, th and scope, complex tables, empty cells, sortable columns, buttons and checkboxes in rows, and scrollable wide tables. Includes a table reader lab, a scrolling region lab, and a live table checker.
ποΈ Introduction to ARIA
Learn what ARIA is and when to use it: roles, properties and states, the five rules of ARIA, why native HTML comes first, what ARIA can and cannot do, and how to check it. Includes a lab that shows ARIA changes meaning but not behaviour, a 'do I need ARIA?' guide, and a live ARIA checker.
ποΈ ARIA Roles
Learn what ARIA roles are, how native HTML elements already have them, and which roles are worth knowing: landmark, widget, live region, and structure roles. Includes a searchable role explorer, a landmark lab that shows what a screen reader's landmark list looks like, and a live roles lab for status, alert, and log.
ποΈ States and Properties
Learn the difference between ARIA states and properties, the kinds of values they take, and the most useful ones: aria-expanded, aria-pressed, aria-checked, aria-selected, aria-current, aria-disabled, aria-invalid, aria-busy, and aria-controls. Includes a state sync lab that shows what goes wrong when state is not updated, a value tester, and a lab for aria-current and aria-busy.
ποΈ Aria Label
Learn when and how to use aria-label: naming icon-only buttons, search fields, repeated landmarks, and SVG images; when not to use it (elements that cannot be named, visible text that already works); the Label in Name rule; and how to write short, unique, translatable labels. Includes a name override lab, a label writing practice, and a live aria-label audit.
ποΈ Aria Labelledby
Learn how aria-labelledby names an element from text that is already on the page: naming dialogs and sections from their headings, building names from several pieces, making repeated buttons unique, how hidden text and self-reference work, and why unique ids matter. Includes a name builder lab, a duplicate id lab, and a live aria-labelledby checker.
ποΈ Aria Describedby
Learn how aria-describedby adds extra help to a control: form hints and errors, warnings on buttons, dialog text, and accessible tooltips. Understand the difference between a name and a description, why descriptions can be missed, and how to keep them accurate. Includes a description builder lab, a tooltip lab for WCAG 1.4.13, and a live aria-describedby checker.
ποΈ Aria Hidden
Learn what aria-hidden really does, when it is safe, and when it quietly breaks your page. Compare hidden, display none, visibility hidden, aria-hidden, inert, and visually hidden text. Never put aria-hidden on something focusable. Includes a hiding-methods lab with real focus tests, a modal background lab, and a live aria-hidden checker.
ποΈ ARIA Live
Learn how aria-live and live region roles announce changes to screen reader users without moving focus: status messages, errors, search results, chat, and timers. Understand polite versus assertive, aria-atomic, aria-relevant, and why a live region must exist before it changes. Includes a live region lab with real regions, an atomic lab, and a live aria-live checker.
ποΈ Accessibility Testing
Learn how to test a web page for accessibility: automated tools, a five-minute keyboard and zoom check, screen reader checks, and testing with real people. Understand what automation can and cannot catch, how to report and fix problems, and how to keep them from coming back. Includes a manual test plan lab, a what-can-a-tool-catch quiz, and a live mini page auditor.
Five Habits to Start Todayβ
- Use the right element. A button for actions, a link for navigation, a heading for a heading.
- Label everything. Every input, every icon button, every image that carries meaning.
- Try your keyboard. Put the mouse aside, and use Tab, Shift+Tab, Enter, Space, and Escape.
- Check contrast and zoom. Enlarge your page to 200 percent, and check the colours.
- Write clearly. Plain words, short sentences, and error messages that say how to fix the problem.
Accessibility Checklist for Any Pageβ
- The page has a
langattribute and a unique<title>. - Headings form a logical outline, and landmarks (
header,nav,main,footer) are used. - Every image has the right
alt, and decorative images havealt="". - Every form control has a visible
<label>. - Links make sense out of context, and buttons say what they do.
- Everything works with the keyboard, and the focus is always visible.
- Text has enough contrast, and information is never shown by colour alone.
- The page works at 200 percent zoom and on small screens.
- Video has captions, and audio has a transcript.
- Animations can be stopped, and respect reduced motion.
- Errors are described in text, and are announced.
Security and Privacy Notesβ
- Do not ask people to prove their disability to use your site, and never store disability information without a clear need and consent. It is sensitive personal data.
- Be careful with accessibility detection. Using a visitor's settings (such as screen reader use, reduced motion, or contrast) to track or profile them can reveal private information. Respond to their preferences in your styles, and do not collect them.
- Accessible does not mean unprotected. CAPTCHAs that rely only on images or sounds shut out many people. Offer an alternative that is both secure and accessible.
- Session timeouts need warnings and a way to extend the time, which is both an accessibility and a security issue.
- Do not put sensitive details in labels and error messages that are read aloud, because others nearby may hear them.
Global Audience Notesβ
- Disability is global, and so are the tools. Many people in lower-income regions use older phones, slower networks, and free screen readers. Lean, semantic HTML serves them best.
- Set
langcorrectly, and mark passages in other languages, so screen readers pronounce them properly. - Right-to-left languages need
dir="rtl"and testing with assistive technology. - Write in plain language, which helps translators, people reading in a second language, and people with cognitive disabilities.
- Laws differ, but many countries now require accessible websites, for example the Americans with Disabilities Act and Section 508 in the United States, the European Accessibility Act in the European Union, and similar rules elsewhere. They often point to WCAG. This is not legal advice, so check the rules for your region and your audience.
- Avoid idioms and cultural shortcuts in icons and instructions.
Common Mistakes to Avoidβ
- Treating accessibility as a last-minute extra.
- Building controls from
divandspaninstead of real elements. - Removing the focus outline.
- Using colour alone to show errors, status, or required fields.
- Missing or meaningless alt text, such as "image" or a file name.
- Placeholder text used as a label.
- Link text such as "click here".
- Adding ARIA by default, and creating wrong or conflicting information.
- Relying only on automatic tools. They find only part of the problems.
- Never testing with a keyboard or a screen reader.
- Auto-playing media, and moving content with no pause.
- Assuming "it looks fine to me" means it is fine.
Practice Timeβ
Try these in your editor and your browser:
- Use the simulator above with each option, and write down what became harder.
- Put your mouse away, and complete a form on a site you use, with the keyboard only.
- Press Tab through your own page, and note every place where you lose track of the focus.
- Check the contrast of three colour pairs on your site, using the checker.
- Zoom a page to 200 percent, and note anything that breaks.
- Turn on a built-in screen reader for five minutes, and listen to a page you built.
- List every image on a page, and write its alt text, or mark it as decorative.
- Replace one
divthat acts as a button with a real<button>. - Run an automatic accessibility checker (such as the one built into your browser's developer tools), and fix the first three issues.
- Bonus: ask a friend who uses assistive technology, if they are happy to help, how they find your site.
Quick Recapβ
Click a question to check your answer.
1. What is web accessibility?
Building websites so that as many people as possible can use them, whatever their abilities, devices, or situations.
2. What does POUR stand for?
Perceivable, Operable, Understandable, and Robust: the four principles of the Web Content Accessibility Guidelines.
3. What is the first rule of ARIA?
If a native HTML element already does the job, use it instead of adding ARIA. ARIA changes what is announced, but it does not add behaviour.
4. What contrast does WCAG level AA require for normal text?
At least 4.5 to 1 between the text and its background. Large text and important non-text parts need at least 3 to 1.
5. Why is the keyboard such an important test?
Many people cannot use a mouse, and screen readers, switch devices, and voice control all depend on keyboard-style navigation. If it works with the keyboard, it is likely to work with other tools.
6. What is the curb-cut effect?
Features built for disabled people, such as ramps or captions, often benefit everyone, including cyclists, parents with pushchairs, and people in noisy places.
Key Takeawaysβ
- Accessibility means building for as many people as possible. Roughly one in six people has a significant disability, and everyone is sometimes limited.
- WCAG rests on four principles: Perceivable, Operable, Understandable, Robust. Level AA is the usual target.
- Semantic HTML is the foundation. Use the right element before you reach for ARIA.
- Test with the keyboard, zoom, contrast checks, and a screen reader, and with real people when you can.
- Never rely on colour alone, never remove the focus outline, and always label controls.
- Protect people's privacy, including information about their disabilities and settings.
- Plain language, lean pages, and correct
langhelp people everywhere.
Ready to begin? Start with Introduction to A11y.