Web accessibility (often shortened to a11y) means building websites that everyone can use, including people who are blind or have low vision, are deaf or hard of hearing, have motor impairments, or have cognitive or learning disabilities. It also helps people with a broken wrist, a bright screen in the sun, a slow connection or an aging parent's eyesight. In 2026 accessibility is both a quality standard and a legal one: laws such as the European Accessibility Act, in force since June 2025, and the Americans with Disabilities Act are routinely applied to websites, and the shared technical yardstick is WCAG 2.2.
This guide is for developers, designers and site owners who know basic HTML and CSS. In 30 minutes you will learn the WCAG principles, semantic page structure, text alternatives, keyboard and focus handling, accessible forms, color contrast and motion, essential ARIA and a practical testing routine. At the end you get a complete web accessibility cheat sheet and a full, accessible event registration page that puts every technique into practice.
| Minutes | What you learn | You can now… |
|---|---|---|
| 0–4 | Who accessibility serves, WCAG and POUR | Explain the standard your site should meet |
| 4–9 | Semantic structure, landmarks and headings | Build pages screen readers can navigate |
| 9–13 | Images, icons and media alternatives | Write useful alt text and captions |
| 13–18 | Keyboard access and focus | Make every feature work without a mouse |
| 18–22 | Accessible forms and errors | Build forms anyone can complete |
| 22–26 | Color, contrast, motion and zoom | Design readable, comfortable interfaces |
| 26–30 | ARIA essentials and testing | Add ARIA safely and audit your own pages |
Try this two-minute check on any page you own. If you cannot see where focus is, or cannot reach something, you have found your first bug.
Keyboard smoke test
Tab / Shift+Tab move forward / back through links, buttons and fields
Enter follow a link, press a button, submit a form
Space press a button, toggle a checkbox
Arrow keys move between radio buttons, select options, menu items
Esc close a dialog or menu
Pass if: every control is reachable, focus is always visible, nothing traps you.The Web Content Accessibility Guidelines (WCAG), published by the W3C, are the international standard. The current version is WCAG 2.2 (October 2023). Its success criteria are graded A (minimum), AA (the usual legal and business target) and AAA (enhanced). Most organizations aim for WCAG 2.2 Level AA.
Every criterion sits under four principles, remembered as POUR:
| Principle | Meaning | Example |
|---|---|---|
| Perceivable | Users can sense the content | Alt text, captions, sufficient contrast |
| Operable | Users can operate the interface | Keyboard access, no time traps, big enough targets |
| Understandable | Content and behavior are clear | Plain language, clear labels, helpful errors |
| Robust | Works with assistive technology | Valid semantic HTML, correct names and roles |
WCAG 2.2 added criteria that are easy to miss, including Focus Not Obscured (a sticky header must not hide the focused element), Target Size (Minimum) of 24 by 24 CSS pixels, Dragging Movements (offer a non-drag alternative), Redundant Entry and Accessible Authentication (no memory puzzles to log in).
Semantic HTML is 80% of accessibility, and it is free. Screen reader users navigate by landmarks (header, nav, main, footer) and by headings, jumping straight to the section they want. Native elements like <button> and <a> come with keyboard support and the correct role automatically; a <div> with a click handler has none of that.
<!DOCTYPE html>
<html lang="en"> <!-- Sets the screen reader's language and voice -->
<head>
<title>Checkout - Step 2 of 3 | Acme Store</title> <!-- Unique, descriptive page title -->
</head>
<body>
<a class="skip-link" href="#main">Skip to main content</a> <!-- First focusable element -->
<header>
<nav aria-label="Main"> <!-- Label distinguishes multiple navs -->
<a href="/">Home</a>
<a href="/shop" aria-current="page">Shop</a> <!-- Announces "current page" -->
</nav>
</header>
<main id="main">
<h1>Shipping details</h1> <!-- One h1 describing the page -->
<h2>Delivery address</h2> <!-- Do not skip levels (h2 to h4) -->
<h2>Delivery speed</h2>
</main>
<footer>…</footer>
</body>
</html>
<!-- Wrong: looks like a button, but no keyboard access, no role, no name -->
<div class="btn" onclick="save()">Save</div>
<!-- Right: focusable, works with Enter and Space, announced as "Save, button" -->
<button type="button" onclick="save()">Save</button>Tip: Use links for navigation (they go somewhere) and buttons for actions (they do something). Screen reader users expect different behavior from each, and the choice also decides which keys activate them.
Every meaningful image needs a text alternative that conveys the same information or purpose. Decorative images get an empty alt="" so screen readers skip them. Icon-only buttons need an accessible name. Video needs captions, and audio-only content needs a transcript.
<!-- Informative: describe what matters in context -->
<img src="chart-q3.png" alt="Bar chart: Q3 revenue rose to $1.2M, up 18% on Q2" width="800" height="450">
<!-- Functional (image inside a link): describe the destination, not the picture -->
<a href="/"><img src="logo.svg" alt="Acme Store home"></a>
<!-- Decorative: empty alt, never omit the attribute -->
<img src="swirl.svg" alt="">
<!-- Icon-only button: hide the icon, give the button a name -->
<button type="button" aria-label="Close cart">
<svg aria-hidden="true" focusable="false" width="20" height="20" viewBox="0 0 20 20">
<path d="M4 4l12 12M16 4L4 16" stroke="currentColor" stroke-width="2"/>
</svg>
</button>
<!-- Or use visually hidden text instead of aria-label -->
<button type="button"><span aria-hidden="true">♥</span><span class="visually-hidden">Add to wishlist</span></button>
<!-- Video with captions and a transcript -->
<video controls preload="metadata">
<source src="product-tour.mp4" type="video/mp4">
<track kind="captions" src="product-tour.en.vtt" srclang="en" label="English" default>
</video>
<a href="/product-tour-transcript">Read the transcript</a>Many people navigate without a mouse: screen reader users, people with tremors or paralysis who use switches or voice control, and power users. Every interactive element must be reachable with Tab, operable with Enter or Space, and show a clearly visible focus indicator. Focus order must follow a logical reading order.
/* Never remove focus outlines without a replacement */
:focus-visible {
outline: 3px solid #f59e0b; /* high-visibility color */
outline-offset: 3px;
}
/* Skip link: hidden until focused, then appears at the top */
.skip-link {
position: absolute;
top: -100px;
left: 1rem;
padding: .75rem 1rem;
background: #111827;
color: #fff;
}
.skip-link:focus { top: 1rem; }
/* Keep focused elements visible below a sticky header (WCAG 2.2) */
html { scroll-padding-top: 5rem; }
/* Comfortable touch and click targets (WCAG 2.2 minimum is 24x24px) */
button, .nav a { min-height: 44px; min-width: 44px; }
/* Hide visually but keep available to screen readers */
.visually-hidden {
position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}<!-- tabindex="0": add a custom widget to the tab order (only if no native element fits) -->
<div role="slider" tabindex="0" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" aria-label="Volume"></div>
<!-- tabindex="-1": focusable by script only (e.g. a heading you move focus to) -->
<h2 id="results" tabindex="-1">12 results</h2>
<!-- Never use a positive tabindex like tabindex="3"; it breaks the natural order -->
<!-- inert: make background content unreachable while a custom panel is open -->
<main inert>…</main>When content changes, manage focus deliberately: move focus into a dialog when it opens and back to the trigger button when it closes; move focus to new results or an error summary after a form submit. The native <dialog> element opened with showModal() handles focus, the Escape key and the inert background for you.
Forms are where accessibility failures cost the most, because they block sign-ups, purchases and support requests. The rules are simple: every field has a visible <label>, related controls are grouped in a <fieldset> with a <legend>, hints and errors are linked with aria-describedby, and errors are described in text, not just shown in red.
<form novalidate>
<p>Fields marked * are required.</p>
<label for="email">Email *</label>
<p id="email-hint">We only use this to send your receipt.</p>
<!-- autocomplete enables autofill (WCAG 1.3.5); aria-describedby reads the hint
and error after the label; aria-invalid is set by script when the value fails -->
<input id="email" name="email" type="email" autocomplete="email" required
aria-describedby="email-hint email-error" aria-invalid="true">
<p id="email-error">Error: enter an email address like name@example.com</p>
<fieldset>
<legend>Delivery speed</legend> <!-- read before each option -->
<label><input type="radio" name="speed" value="standard" checked> Standard (free)</label>
<label><input type="radio" name="speed" value="express"> Express ($9)</label>
</fieldset>
<button type="submit">Continue to payment</button>
</form>Tip: Placeholder text is not a label. It disappears when typing starts, often has low contrast and is not reliably announced. Use a real label and, if needed, a hint paragraph linked with
aria-describedby.
On submit, if there are errors, show an error summary at the top of the form that lists each problem as a link to its field, and move focus to that summary so screen reader users hear it immediately. The complete example below shows the full pattern in JavaScript.
Low contrast is one of the most common accessibility failures on the web. WCAG AA requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (24px regular or about 18.66px bold), and 3:1 for interface parts like input borders, icons and focus indicators. Also, never use color as the only way to convey information: pair it with text, an icon or a pattern.
| Content | Minimum ratio (AA) | Example that passes on white |
|---|---|---|
| Body text | 4.5:1 | #4b5563 gray |
| Large text | 3:1 | #6b7280 gray at 24px |
| UI components and graphics | 3:1 | #767676 input border |
| Disabled controls and pure decoration | No requirement | Still keep them readable where you can |
/* Color plus text/icon, never color alone */
.status-error { color: #b91c1c; } /* red text... */
.status-error::before { content: "✕ "; } /* ...plus a symbol, and the word "Error" in the HTML */
/* Respect users who get dizzy or distracted by motion */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}
/* Support zoom and reflow: relative units, no fixed heights on text */
body { font-size: 1rem; line-height: 1.5; }
.card { min-height: 10rem; } /* min-height, not height, so text can grow */
/* Honor forced colors (Windows High Contrast) */
@media (forced-colors: active) {
.btn { border: 2px solid ButtonText; }
}Pages must also work at 200% zoom and reflow into a single column at 320 CSS pixels wide without horizontal scrolling (except for content like data tables and maps). Never disable pinch-zoom in your viewport meta tag.
ARIA (Accessible Rich Internet Applications) attributes add roles, states and names that HTML cannot express on its own. The first rule of ARIA is: if a native HTML element does the job, use it instead. ARIA changes only what assistive technology announces; it adds no keyboard behavior. Wrong ARIA is worse than none.
<!-- Disclosure (show/hide) button: aria-expanded announces open/closed -->
<button type="button" aria-expanded="false" aria-controls="filters">Filters</button>
<div id="filters" hidden>…</div>
<!-- Toggle button: aria-pressed announces on/off -->
<button type="button" aria-pressed="false">Show only open jobs</button>
<!-- Live regions: announce dynamic updates without moving focus -->
<p role="status">3 items added to cart</p> <!-- polite: waits for a pause -->
<p role="alert">Your session expires in 1 minute</p> <!-- assertive: interrupts -->
<!-- Name a region or widget from visible text -->
<section aria-labelledby="reviews-title">
<h2 id="reviews-title">Customer reviews</h2>
</section>
<!-- Hide purely decorative or duplicate content from screen readers -->
<span aria-hidden="true">★★★★☆</span><span class="visually-hidden">Rated 4 out of 5</span>// Keep ARIA state in sync with what the user sees
const btn = document.querySelector('[aria-controls="filters"]');
const panel = document.getElementById('filters');
btn.addEventListener('click', () => {
const open = btn.getAttribute('aria-expanded') === 'true';
btn.setAttribute('aria-expanded', String(!open));
panel.hidden = open;
});| Technique | What it does | Example |
|---|---|---|
lang | Sets page language for pronunciation | <html lang="en"> |
<title> | Unique page name, first thing announced | <title>Cart | Acme</title> |
| Landmarks | Navigable page regions | <header> <nav> <main> <footer> |
| Headings | Logical outline, no skipped levels | <h1> then <h2> |
| Skip link | Bypass repeated navigation | <a href="#main">Skip to content</a> |
aria-current | Marks the current page in navigation | aria-current="page" |
Informative alt | Text alternative for images | alt="Team at the 2026 launch" |
Empty alt | Decorative image, skipped | alt="" |
| SVG icon | Hide icon, name the control | <svg aria-hidden="true" focusable="false"> |
| Captions | Text for video speech and sounds | <track kind="captions"> |
| Transcript | Text version of audio or video | <a href="/transcript">Transcript</a> |
| Descriptive links | Make sense out of context | Download the 2026 price list (PDF) |
| Data tables | Caption and header scope | <th scope="col">Price</th> |
| Language changes | Correct pronunciation of phrases | <span lang="fr">bonjour</span> |
| Technique | What it does | Example |
|---|---|---|
| Native controls | Built-in keyboard and roles | <button>, <a href>, <select> |
:focus-visible | Visible keyboard focus | outline: 3px solid #f59e0b; |
tabindex="0" | Add a custom widget to tab order | <div role="slider" tabindex="0"> |
tabindex="-1" | Focusable by script only | heading.focus() |
| No positive tabindex | Keep natural order | Avoid tabindex="5" |
inert | Disable a whole region | <main inert> |
<dialog> + showModal() | Modal with focus handling and Esc | dialog.showModal() |
scroll-padding-top | Focused items not hidden by sticky headers | html { scroll-padding-top: 5rem; } |
| Target size | At least 24×24px (44px preferred) | min-height: 44px; |
<label for> | Visible, linked field name | <label for="email">Email</label> |
<fieldset> + <legend> | Name a group of controls | <legend>Payment method</legend> |
aria-describedby | Link hints and errors to a field | aria-describedby="pw-hint" |
aria-invalid | Mark a field as invalid | aria-invalid="true" |
autocomplete | Identify input purpose, enable autofill | autocomplete="postal-code" |
| Error summary | List errors, link to fields, receive focus | summary.focus() |
| Required fields | Indicate in text and attribute | required + "Required" in label |
| Technique | What it does | Example |
|---|---|---|
| Text contrast | 4.5:1 normal, 3:1 large | #4b5563 on white |
| Non-text contrast | 3:1 for borders, icons, focus rings | border: 2px solid #767676; |
| Not color alone | Add text, icons or patterns | "Error:" prefix plus red |
prefers-reduced-motion | Tone down animation | @media (prefers-reduced-motion: reduce) |
forced-colors | Support high contrast modes | @media (forced-colors: active) |
| Reflow and zoom | Usable at 320px and 200% zoom | Relative units, no fixed heights |
aria-label | Name a control with no visible text | aria-label="Search" |
aria-labelledby | Name from visible text elsewhere | aria-labelledby="dlg-title" |
aria-expanded | Open/closed state | aria-expanded="true" |
aria-pressed | Toggle button state | aria-pressed="false" |
aria-controls | Points to the element a control affects | aria-controls="menu" |
aria-hidden="true" | Hide from assistive tech | <span aria-hidden="true">★</span> |
role="status" | Polite live announcement | <p role="status"></p> |
role="alert" | Urgent live announcement | <div role="alert"></div> |
<html lang="en"> <!-- page language -->
<title>Page purpose | Site name</title> <!-- unique title -->
<a class="skip-link" href="#main">Skip to main content</a> <!-- skip link -->
<nav aria-label="Main"><a href="/" aria-current="page">Home</a></nav>
<main id="main"><h1>One clear heading</h1></main> <!-- landmark + h1 -->
<img src="team.jpg" alt="Describe what matters"> <!-- informative image -->
<img src="flourish.svg" alt=""> <!-- decorative image -->
<button type="button" aria-label="Close"><svg aria-hidden="true" focusable="false">…</svg></button>
<label for="email">Email (required)</label> <!-- visible label -->
<input id="email" type="email" autocomplete="email" required aria-describedby="email-err">
<p id="email-err" hidden>Error: enter a valid email</p> <!-- linked error -->
<button type="button" aria-expanded="false" aria-controls="panel">Details</button>
<p role="status"></p> <!-- live updates -->
<style>
:focus-visible { outline: 3px solid #f59e0b; outline-offset: 3px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
</style><div>s and <span>s → use <button> or <a href>, which come with keyboard support and roles.:focus-visible style instead.alt="image123.jpg") → describe the purpose, or use alt="" for decoration.<label> linked with for.aria-describedby and set aria-invalid.role="button" on a <button>, aria-label that hides visible text) → use native HTML first and ARIA only to fill real gaps.This registration page for a fictional conference, "Open Web Meetup 2026", applies every technique from the guide: page language and title, skip link, landmarks, aria-current, a heading outline, informative and decorative images, captioned video with a transcript link, an accessible data table, a toggle button with aria-pressed, a disclosure menu with aria-expanded, a live region, a form with labels, hints, fieldset, autocomplete, inline errors and a focused error summary, a native modal dialog with a named icon button, visible focus styles, contrast-safe colors, large targets, reduced motion and forced-colors support.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <!-- zoom allowed -->
<title>Register | Open Web Meetup 2026</title>
<style>
/* CONTRAST-SAFE COLORS: every text color passes 4.5:1 on white (Minutes 22–26) */
:root { --text: #1a1a2e; --muted: #4b5563; --brand: #1d4ed8; --error: #b91c1c; --focus: #f59e0b; }
body { margin: 0; font: 1.0625rem/1.6 system-ui, sans-serif; color: var(--text); background: #fff; }
header, main, footer { max-width: 46rem; margin-inline: auto; padding-inline: 1rem; }
a { color: var(--brand); } img, video { max-width: 100%; height: auto; }
/* FOCUS, SKIP LINK AND TARGET SIZE (Minutes 13–18) */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.skip-link { position: absolute; left: 1rem; top: -100px; background: var(--text); color: #fff; padding: .75rem 1rem; }
.skip-link:focus { top: 1rem; } /* appears on first Tab */
button { min-height: 44px; min-width: 44px; padding: .5rem 1rem; font: inherit; cursor: pointer; }
nav ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem; }
[aria-current="page"] { font-weight: 700; text-decoration-thickness: 3px; }
@media (min-width: 48rem) { #menu-btn { display: none; } #menu[hidden] { display: flex; } }
/* TABLE + FORM: 3:1 borders, errors shown with words AND color */
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid #767676; }
label, legend { display: block; font-weight: 600; margin-top: 1rem; }
.choice { font-weight: 400; margin-top: .25rem; }
input[type="text"], input[type="email"] { width: 100%; padding: .6rem; font: inherit; border: 2px solid #767676; border-radius: 6px; }
[aria-invalid="true"] { border: 3px solid var(--error); }
.hint { color: var(--muted); margin: .25rem 0; } .error { color: var(--error); font-weight: 600; margin: .25rem 0; }
#error-summary { border: 4px solid var(--error); padding: 1rem; }
/* MOTION + FORCED COLORS (Minutes 22–26) */
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media (forced-colors: active) { button { border: 2px solid ButtonText; } }
</style>
</head>
<body>
<!-- SKIP LINK, LANDMARKS, DISCLOSURE MENU (Minutes 4–9, 26–30) -->
<a class="skip-link" href="#main">Skip to main content</a>
<header>
<p><strong>Open Web Meetup</strong></p>
<nav aria-label="Main">
<button type="button" id="menu-btn" aria-expanded="false" aria-controls="menu">Menu</button>
<ul id="menu" hidden><li><a href="/about">About</a></li><li><a href="/speakers">Speakers</a></li>
<li><a href="/register" aria-current="page">Register</a></li></ul>
</nav>
</header>
<main id="main" tabindex="-1">
<h1>Register for Open Web Meetup 2026</h1>
<p>A free, one-day event about inclusive websites on <time datetime="2026-12-05">Saturday, December 5, 2026</time>.</p>
<!-- IMAGES + MEDIA ALTERNATIVES (Minutes 9–13) -->
<img src="venue.jpg" alt="Main hall with rows of chairs facing a stage and a large screen" width="800" height="450">
<img src="divider.svg" alt="">
<video controls preload="metadata" width="800" height="450" src="welcome.mp4">
<track kind="captions" src="welcome.en.vtt" srclang="en" label="English" default>
</video>
<p><a href="/welcome-transcript">Read the welcome video transcript</a></p>
<!-- DATA TABLE + TOGGLE BUTTON + LIVE REGION (Minutes 26–30) -->
<h2>Schedule</h2>
<button type="button" id="filter-btn" aria-pressed="false">Beginner-friendly talks only</button>
<table id="schedule">
<caption>Talks on December 5, Main hall</caption>
<thead><tr><th scope="col">Time</th><th scope="col">Talk</th><th scope="col">Level</th></tr></thead>
<tbody>
<tr data-level="beginner"><td>09:30</td><th scope="row">Semantic HTML that sells</th><td>Beginner</td></tr>
<tr data-level="advanced"><td>11:00</td><th scope="row">Accessible custom widgets</th><td>Advanced</td></tr>
<tr data-level="beginner"><td>13:30</td><th scope="row">Color contrast in practice</th><td>Beginner</td></tr>
</tbody>
</table>
<p id="status" role="status"></p>
<!-- ACCESSIBLE FORM + ERROR SUMMARY (Minutes 18–22) -->
<h2 id="form-title">Your details</h2>
<div id="error-summary" tabindex="-1" hidden><h3></h3><ul></ul></div>
<form id="reg-form" aria-labelledby="form-title" novalidate>
<p>All fields are required.</p>
<label for="name">Full name</label>
<input type="text" id="name" name="name" autocomplete="name" required aria-describedby="name-error">
<p id="name-error" class="error" hidden></p>
<label for="email">Email</label>
<p id="email-hint" class="hint">We will send your ticket to this address.</p>
<input type="email" id="email" name="email" autocomplete="email" required aria-describedby="email-hint email-error">
<p id="email-error" class="error" hidden></p>
<fieldset>
<legend>Which track will you attend?</legend>
<label class="choice"><input type="radio" name="track" value="design" checked> Design</label>
<label class="choice"><input type="radio" name="track" value="development"> Development</label>
</fieldset>
<p><button type="button" id="coc-btn">Read the code of conduct</button></p>
<label class="choice"><input type="checkbox" id="terms" name="terms" required aria-describedby="terms-error"> I agree to the code of conduct</label>
<p id="terms-error" class="error" hidden></p>
<p><button type="submit">Register for free</button></p>
</form>
</main>
<!-- NATIVE MODAL DIALOG + NAMED ICON BUTTON (Minutes 13–18) -->
<dialog id="coc" aria-labelledby="coc-title">
<form method="dialog"><button aria-label="Close code of conduct"><span aria-hidden="true">✕</span></button></form>
<h2 id="coc-title">Code of conduct</h2>
<p>Be respectful, assume good intent and make room for every voice.</p>
</dialog>
<footer><p>Questions? Email <a href="mailto:access@example.com">access@example.com</a></p></footer>
<script>
const byId = (id) => document.getElementById(id), status = byId('status');
// Disclosure menu: aria-expanded mirrors visibility
byId('menu-btn').addEventListener('click', (e) => {
const open = e.currentTarget.getAttribute('aria-expanded') === 'true';
e.currentTarget.setAttribute('aria-expanded', String(!open));
byId('menu').hidden = open;
});
// Toggle button (aria-pressed) + polite live-region announcement
byId('filter-btn').addEventListener('click', (e) => {
const pressed = e.currentTarget.getAttribute('aria-pressed') !== 'true';
e.currentTarget.setAttribute('aria-pressed', String(pressed));
const rows = [...document.querySelectorAll('#schedule tbody tr')];
rows.forEach((row) => { row.hidden = pressed && row.dataset.level !== 'beginner'; });
status.textContent = `Showing ${rows.filter((r) => !r.hidden).length} of ${rows.length} talks.`;
});
// Native dialog: focus moves in, Esc closes, focus returns to the button
byId('coc-btn').addEventListener('click', () => byId('coc').showModal());
// Validation: text errors, aria-invalid and a focused error summary
const checks = [
{ id: 'name', message: 'Enter your full name', valid: (el) => el.value.trim() !== '' },
{ id: 'email', message: 'Enter an email address like name@example.com', valid: (el) => el.validity.valid },
{ id: 'terms', message: 'Confirm that you agree to the code of conduct', valid: (el) => el.checked },
];
byId('reg-form').addEventListener('submit', (event) => {
event.preventDefault();
const errors = [];
for (const { id, message, valid } of checks) {
const ok = valid(byId(id));
byId(id).setAttribute('aria-invalid', String(!ok));
byId(`${id}-error`).textContent = ok ? '' : `Error: ${message}`; // words, not just red
byId(`${id}-error`).hidden = ok;
if (!ok) errors.push({ id, message });
}
const summary = byId('error-summary');
if (errors.length > 0) {
summary.querySelector('h3').textContent =
`There ${errors.length === 1 ? 'is 1 problem' : `are ${errors.length} problems`} with your registration`;
summary.querySelector('ul').replaceChildren(...errors.map(({ id, message }) => {
const li = document.createElement('li');
li.append(Object.assign(document.createElement('a'), { href: `#${id}`, textContent: message }));
return li;
}));
summary.hidden = false;
summary.focus(); // announced immediately
} else {
summary.hidden = true;
event.target.reset();
status.textContent = 'Thank you! You are registered. Your ticket is on its way.';
}
});
</script>
</body>
</html>register.html and open it in any modern browser. The images and video show as placeholders, which also lets you see how alt text behaves when an image fails to load.:focus-visible ring, a skip link, 44px targets, and reduced-motion and forced-colors support.nav landmark with a disclosure menu (aria-expanded, aria-controls) and aria-current="page".alt="", captions via <track> and a transcript link.aria-pressed toggle and a role="status" live region that announces the filter result.aria-describedby, autocomplete, a radio fieldset, and validation that sets aria-invalid, writes text errors and focuses a linked error summary.showModal(), named by its heading via aria-labelledby, with an icon-only close button named by aria-label.alt="".aria-pressed.Aim for WCAG 2.2 Level AA. It is the level referenced by most accessibility laws and procurement policies, and it covers the issues that affect the most users. Level AAA is great for specific content but is rarely required for an entire site.
No tool injected on top of a page can fix missing labels, broken keyboard support or poor structure reliably, and many disabled users find overlays get in the way. Accessibility has to be built into the HTML, CSS and JavaScript of the site itself.
Yes, in several ways. Semantic headings, descriptive link text, alt text, captions and transcripts give search engines and AI assistants clearer content to understand, and accessible sites tend to be faster and easier to use, which supports engagement.
It depends on size and how the site was built. Fixing contrast, alt text, labels and focus styles can take days; rebuilding inaccessible custom widgets can take longer. Starting with an audit of your most important user journeys gives the fastest results.
You now know the essentials of web accessibility: WCAG and POUR, semantic structure, text alternatives, keyboard and focus, forms, contrast and motion, ARIA and testing. If you want an accessibility audit or a website built to WCAG 2.2 AA from day one, FikarFix can help: talk to our team.