FikarFix...

Learn Web Accessibility in 30 Minutes — With Cheat Sheet Code

Learn Web Accessibility in 30 Minutes — With Cheat Sheet Code
Nov 26, 2026 Tutorials 15 views

Learn Web Accessibility in 30 Minutes — With Cheat Sheet Code

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.

Your 30-minute plan

MinutesWhat you learnYou can now…
0–4Who accessibility serves, WCAG and POURExplain the standard your site should meet
4–9Semantic structure, landmarks and headingsBuild pages screen readers can navigate
9–13Images, icons and media alternativesWrite useful alt text and captions
13–18Keyboard access and focusMake every feature work without a mouse
18–22Accessible forms and errorsBuild forms anyone can complete
22–26Color, contrast, motion and zoomDesign readable, comfortable interfaces
26–30ARIA essentials and testingAdd ARIA safely and audit your own pages

Before you start

  • A browser with DevTools: Chrome, Edge and Firefox include an accessibility tree viewer and contrast checker. Lighthouse in Chrome runs a quick automated audit.
  • A free checker extension: axe DevTools, WAVE or Accessibility Insights for Web find many common issues in seconds.
  • A screen reader: NVDA is free on Windows; VoiceOver is built into macOS and iOS (Cmd+F5 on a Mac); TalkBack is built into Android.
  • Your keyboard: the single most useful testing tool. Put the mouse aside and press Tab.

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.

Minutes 0–4: Who it is for, WCAG and POUR

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:

PrincipleMeaningExample
PerceivableUsers can sense the contentAlt text, captions, sufficient contrast
OperableUsers can operate the interfaceKeyboard access, no time traps, big enough targets
UnderstandableContent and behavior are clearPlain language, clear labels, helpful errors
RobustWorks with assistive technologyValid 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).

Minutes 4–9: Semantic structure, landmarks and headings

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.

Minutes 9–13: Images, icons and media alternatives

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>

Writing good alt text

  • Be specific and short: usually one sentence. Skip "image of" or "picture of"; screen readers already say "image".
  • Describe the purpose in context: the same photo may need different alt text on a product page and on a team page.
  • For complex charts, give the key takeaway in alt and the full data in a nearby table or text.
  • Never put essential text only inside an image; if you must, repeat the text in the alt.

Minutes 13–18: Keyboard access and focus

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.

Minutes 18–22: Accessible forms and errors

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.

Minutes 22–26: Color, contrast, motion and zoom

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.

ContentMinimum ratio (AA)Example that passes on white
Body text4.5:1#4b5563 gray
Large text3:1#6b7280 gray at 24px
UI components and graphics3:1#767676 input border
Disabled controls and pure decorationNo requirementStill 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.

Minutes 26–30: ARIA essentials and testing

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;
});

A practical testing routine

  1. Automated scan: run axe DevTools, WAVE or Lighthouse. Fix everything they flag; they catch only part of the problems, so keep going.
  2. Keyboard pass: complete every task with Tab, Shift+Tab, Enter, Space, arrows and Esc. Watch the focus indicator throughout.
  3. Screen reader pass: with NVDA or VoiceOver, list the headings and landmarks, then fill in and submit your main form.
  4. Zoom and reflow: zoom to 200% and 400%, and check the page at 320px wide.
  5. Visual checks: verify contrast with DevTools, and turn on reduced motion and Windows contrast themes.
  6. Real users: whenever possible, test with disabled people; they find issues no checklist does.

Web Accessibility cheat sheet

Structure, text and media

TechniqueWhat it doesExample
langSets page language for pronunciation<html lang="en">
<title>Unique page name, first thing announced<title>Cart | Acme</title>
LandmarksNavigable page regions<header> <nav> <main> <footer>
HeadingsLogical outline, no skipped levels<h1> then <h2>
Skip linkBypass repeated navigation<a href="#main">Skip to content</a>
aria-currentMarks the current page in navigationaria-current="page"
Informative altText alternative for imagesalt="Team at the 2026 launch"
Empty altDecorative image, skippedalt=""
SVG iconHide icon, name the control<svg aria-hidden="true" focusable="false">
CaptionsText for video speech and sounds<track kind="captions">
TranscriptText version of audio or video<a href="/transcript">Transcript</a>
Descriptive linksMake sense out of contextDownload the 2026 price list (PDF)
Data tablesCaption and header scope<th scope="col">Price</th>
Language changesCorrect pronunciation of phrases<span lang="fr">bonjour</span>

Keyboard, focus and forms

TechniqueWhat it doesExample
Native controlsBuilt-in keyboard and roles<button>, <a href>, <select>
:focus-visibleVisible keyboard focusoutline: 3px solid #f59e0b;
tabindex="0"Add a custom widget to tab order<div role="slider" tabindex="0">
tabindex="-1"Focusable by script onlyheading.focus()
No positive tabindexKeep natural orderAvoid tabindex="5"
inertDisable a whole region<main inert>
<dialog> + showModal()Modal with focus handling and Escdialog.showModal()
scroll-padding-topFocused items not hidden by sticky headershtml { scroll-padding-top: 5rem; }
Target sizeAt 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-describedbyLink hints and errors to a fieldaria-describedby="pw-hint"
aria-invalidMark a field as invalidaria-invalid="true"
autocompleteIdentify input purpose, enable autofillautocomplete="postal-code"
Error summaryList errors, link to fields, receive focussummary.focus()
Required fieldsIndicate in text and attributerequired + "Required" in label

Color, motion and ARIA

TechniqueWhat it doesExample
Text contrast4.5:1 normal, 3:1 large#4b5563 on white
Non-text contrast3:1 for borders, icons, focus ringsborder: 2px solid #767676;
Not color aloneAdd text, icons or patterns"Error:" prefix plus red
prefers-reduced-motionTone down animation@media (prefers-reduced-motion: reduce)
forced-colorsSupport high contrast modes@media (forced-colors: active)
Reflow and zoomUsable at 320px and 200% zoomRelative units, no fixed heights
aria-labelName a control with no visible textaria-label="Search"
aria-labelledbyName from visible text elsewherearia-labelledby="dlg-title"
aria-expandedOpen/closed statearia-expanded="true"
aria-pressedToggle button statearia-pressed="false"
aria-controlsPoints to the element a control affectsaria-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>

Copy-paste starter

<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>

Common beginner mistakes

  • Clickable <div>s and <span>s → use <button> or <a href>, which come with keyboard support and roles.
  • Removing the focus outline → replace it with a stronger :focus-visible style instead.
  • Missing or useless alt text (alt="image123.jpg") → describe the purpose, or use alt="" for decoration.
  • Placeholder instead of label → add a visible <label> linked with for.
  • Errors shown only in red → write the error in text, link it with aria-describedby and set aria-invalid.
  • Adding ARIA everywhere (role="button" on a <button>, aria-label that hides visible text) → use native HTML first and ARIA only to fill real gaps.
  • Relying on an automated score → a 100 in Lighthouse does not mean accessible; always do keyboard and screen reader checks.

Complete example: everything in one file

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>

How to run it

  1. Save the code as 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.
  2. Press Tab once: the skip link appears. Press Enter to jump to the main content.
  3. Keep tabbing through the page, toggle the schedule filter with Space and open the code of conduct dialog; press Esc to close it and notice focus returns to the button.
  4. Submit the empty form: the error summary receives focus, each field shows a text error and the links jump to the fields.
  5. Turn on NVDA or VoiceOver and repeat. Then run axe DevTools or Lighthouse for an automated check.

What each part does

  • Head and styles: page language and title, zoom-friendly viewport, contrast-safe color tokens, a strong :focus-visible ring, a skip link, 44px targets, and reduced-motion and forced-colors support.
  • Header: a labeled nav landmark with a disclosure menu (aria-expanded, aria-controls) and aria-current="page".
  • Images and video: an informative image with descriptive alt, a decorative image with alt="", captions via <track> and a transcript link.
  • Schedule: a captioned table with column and row headers, an aria-pressed toggle and a role="status" live region that announces the filter result.
  • Form: visible labels, a hint linked with aria-describedby, autocomplete, a radio fieldset, and validation that sets aria-invalid, writes text errors and focuses a linked error summary.
  • Dialog: a native modal opened with showModal(), named by its heading via aria-labelledby, with an icon-only close button named by aria-label.

Practice challenges

  1. Audit your own home page with the keyboard only and write down every element you could not reach or see focused.
  2. Rewrite the alt text for five images on your site, and mark purely decorative ones with alt="".
  3. Add a password field to the example with a hint about requirements and a "Show password" toggle that uses aria-pressed.
  4. Build an accessible tabs component following the ARIA Authoring Practices Guide pattern, with arrow-key navigation between tabs.
  5. Run a full screen reader test of your checkout or contact form with NVDA or VoiceOver and fix every confusing announcement.

What to learn next

Frequently asked questions

What level of WCAG should my website meet?

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.

Can an accessibility overlay or widget make my site compliant?

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.

Does accessibility help SEO?

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.

How long does it take to make an existing site accessible?

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.

Need a Project Done?

From websites to research support — tell us what you need.

Get a Quote