Skip to content
webtechos

Web Accessibility (a11y) Masterclass for Modern UI Engineers

A practical WCAG 2.2 guide for UI engineers: real component patterns, axe-core and Playwright testing, and what automation still misses.

5 Sept 2026·15 min read·General

Lighthouse says 100. Axe-core comes back clean. Then a customer using a screen reader calls support because they cannot find the submit button, the one labeled only "button," and nothing on the QA board ever flagged it.

That gap is not an edge case. Automated tools catch roughly 57% of what WCAG actually requires, and this year's WebAIM Million audit found an average of 56 detectable errors on every one of the top million home pages, worse than the year before. The other 43%, focus order, whether alt text means anything, whether a custom dropdown behaves like a dropdown to someone who cannot see it, is where almost nobody is looking.

This post closes that gap for engineers, not lawyers. You will get the four WCAG 2.2 criteria that actually change your code, working patterns for the components responsible for the most support tickets (modals, combo boxes, skip links, live regions), a CI setup with axe-core and Playwright that catches regressions before they ship, and a clear line between what automation can verify and what still needs a person at a keyboard.


The web got less accessible in 2026, not more

For six years running, the WebAIM Million audit of the top one million home pages showed accessibility slowly improving. The 2026 edition broke that streak. Detectable WCAG failures now show up on 95.9% of home pages, up from 94.8%, and the average page carries 56.1 automatically detectable errors, a 10% jump from the year before.

The same six problems have topped that list for seven straight years, and none of them require deep accessibility expertise to fix:

  • Low contrast text, found on 83.9% of pages

  • Missing alt text on images, on more than half of pages

  • Unlabeled form inputs, roughly a third of the 6.9 form fields the average page now carries

  • Empty links

  • Empty buttons

  • Missing document language

One finding is worth sitting with if your team leans on ARIA for custom components. Pages that used ARIA averaged 59.1 errors, compared to 42 on pages that used none. The W3C's own guidance is blunt about why. No ARIA is better than bad ARIA. Slapping role="button" on a div without the keyboard handling, focus management, and state announcements that role implies makes a page worse than leaving the native <button> alone.

None of this is exotic. It is semantic HTML, labeled inputs, and contrast ratios, at scale, still unfixed.


WCAG 2.2: the parts that actually change your code

WCAG 2.2 added nine new success criteria. Four of them show up in a code review rather than a legal document, and they are worth treating as a checklist even though one sits at a stricter conformance level than the rest.

Target Size (2.5.8, Level AA). Every pointer target needs to be at least 24 by 24 CSS pixels, or have enough spacing that a 24px circle centered on it does not overlap a neighboring target. A 16px icon button with 4px of padding on every side clears this. An icon button with no padding does not, even if it looks fine on a desktop pointer.

css

.icon-button {
  width: 16px;
  height: 16px;
  padding: 4px; /* brings the hit area to 24x24 */
}
target-size-wcag22 (2)

Focus Appearance (2.4.13, Level AAA). This one is technically above the AA bar most teams target, but it is worth building anyway. When an element is focused, the indicator needs a contrasting area at least as large as a 2px outline around the control, with a 3:1 contrast ratio between the focused and unfocused states. It is the rule that punishes outline: none without a real replacement, and meeting it costs nothing extra if you set it up right the first time.

css

:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}

Dragging Movements (2.5.7, Level AA). Anything that requires a drag gesture, reordering a list, adjusting a slider by dragging the handle, needs a non-dragging alternative. A keyboard-operable up and down arrow pair, or buttons that move an item one position at a time, satisfies this without redesigning the interaction.

Focus Not Obscured (2.4.11, Level AA). When an element receives focus, something else on the page, usually a sticky header or a cookie banner, cannot cover it completely. This is a z-index and scroll-margin-top problem as often as it is a design problem.

Run through these four on your next sprint's acceptance criteria and you will have closed the gap between WCAG 2.1 and 2.2 for most of a typical product UI.


The component patterns that actually need a masterclass

Automated tools can confirm an <img> has an alt attribute. They cannot confirm your custom combobox behaves like a combobox. That is where real engineering judgment lives, and where most teams are weakest.

Modals and focus traps

A modal that does not manage focus lets a keyboard user tab straight through it into the page behind it. The pattern that works:

jsx

function Modal({ onClose, children }) {
  const modalRef = useRef(null);

  useEffect(() => {
    const modal = modalRef.current;
    const focusable = modal.querySelectorAll(
      'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
    );
    const first = focusable[0];
    const last = focusable[focusable.length - 1];
    first?.focus();

    function trap(e) {
      if (e.key === 'Escape') return onClose();
      if (e.key !== 'Tab') return;
      if (e.shiftKey && document.activeElement === first) {
        e.preventDefault();
        last.focus();
      } else if (!e.shiftKey && document.activeElement === last) {
        e.preventDefault();
        first.focus();
      }
    }

    modal.addEventListener('keydown', trap);
    return () => modal.removeEventListener('keydown', trap);
  }, [onClose]);

  return (
    <div role="dialog" aria-modal="true" ref={modalRef}>
      {children}
    </div>
  );
}

This pattern covers three things an axe scan will not check on its own. Focus moves into the dialog on open, Tab and Shift+Tab stay inside it, and Escape closes it. Two pieces are still missing before you'd call this done, returning focus to whatever triggered the modal once it closes, and re-querying the focusable elements if the modal's content changes after it opens, since the version above only grabs them once on mount.

focus-trap-tab-order (2)

Accessible comboboxes and autocomplete

A <div> styled to look like a dropdown, with options rendered as more <div>s, is invisible to a screen reader unless you build the full ARIA combobox pattern from the WAI-ARIA Authoring Practices: role="combobox" on the input wrapper, aria-expanded, aria-controls pointing at the listbox id, role="listbox" and role="option" on the results, and arrow-key handling that moves aria-activedescendant without moving DOM focus. Get any one of those pieces wrong and the whole pattern reads as a plain text box to assistive technology, even though it looks identical to a sighted user.

Skip links and landmarks

A skip link sounds like a solved problem from 2005, and it is one of the most commonly broken things on modern sites because frameworks route client-side without resetting focus.

html

<a class="skip-link" href="#main-content">Skip to main content</a>
...
<main id="main-content" tabindex="-1">

The tabindex="-1" matters here. It lets the link programmatically move focus to <main> without adding it to the normal tab order. On a single-page app, the same focus-shift needs to happen on every route change, or keyboard and screen reader users land back at the top of the page after every navigation.

Live regions for dynamic content

A toast notification, a form validation error, or a cart count that updates without a page reload is invisible to a screen reader unless it lives inside an aria-live region.

html

<div aria-live="polite" aria-atomic="true">
  {errorMessage}
</div>

polite waits for the screen reader to finish whatever it is currently announcing. assertive interrupts immediately, which you want for something like a failed payment, and almost nowhere else.


Where AI coding agents get accessibility wrong

Coding agents like Cursor and Claude Code have started running accessibility checks automatically, usually by calling axe-core, seeing a clean result, and marking the ticket done. The problem is what "clean" means here. Axe-core's own project documentation puts its automatic detection rate at roughly 57% of WCAG issues. The rest, focus order, whether an image's alt text is actually meaningful, whether a custom widget behaves correctly when exercised, needs a human or a much more deliberate test.

In practice, an agent asked to fix an accessibility violation will often take the fastest path that satisfies the scanner, an empty alt="" on a product photo, a generic aria-label="button" that clears the rule but tells a screen reader user nothing useful. The fix passes CI and fails the person it was supposedly written for.

This does not mean skip the automation. It means treat an agent's "fixed" the same way you would treat a junior engineer's first pass, a reasonable starting point that still needs review before merge. If you're deciding which agent to lean on for this kind of refactor, our Cursor vs Claude Code comparison walks through how each handles larger, multi-file changes, which is exactly the situation where a rushed accessibility fix is most likely to slip through unreviewed.


Building a testing stack that catches regressions, not just launch-day bugs

A one-time audit tells you where you stand today. It says nothing about the modal someone ships next sprint. The fix is making accessibility a gate in CI, the same way you gate on unit tests.

Playwright with @axe-core/playwright is the standard combination for teams building new test suites in 2026, and it reads almost exactly like a normal end-to-end test:

js

import { test, expect } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';

test('checkout page has no automatically detectable violations', async ({ page }) => {
  await page.goto('/checkout');
  const results = await new AxeBuilder({ page })
    .withTags(['wcag2a', 'wcag2aa', 'wcag22aa'])
    .analyze();

  expect(results.violations).toEqual([]);
});

A few things make this actually useful instead of a box-checking exercise:

  • Test the state, not just the route. Open the modal, expand the dropdown, trigger the validation error, and run the scan again in each state. Axe only sees the DOM as it exists at the moment you call analyze().

  • Set a threshold and ratchet it down. If you are retrofitting this onto an existing app with years of accumulated issues, failing the build on every violation on day one guarantees the check gets disabled within a week. Start by failing only on new violations above a baseline, then tighten the baseline every sprint.

  • Add a keyboard-only pass by hand. Tab through the page without touching your mouse. If you lose track of where focus is at any point, so will every keyboard-only user.

  • Test with an actual screen reader occasionally. NVDA on Windows and VoiceOver on macOS are both free. Thirty minutes a sprint navigating your highest-traffic flow with one of them catches things no automated tool will ever flag, like an alt text that technically exists but says "image1234.jpg."

This is the layer most teams skip, and it is the layer that separates a page that passes a scan from a page a disabled person can actually complete a task on.


If your team is weighing whether this is worth the engineering time against a quarter's other priorities, the numbers from 2026 make the case on their own. UsableNet's midyear tracking put digital accessibility lawsuits on pace for roughly 6,176 filings in the US this year, close to 20% above 2025 and the highest total on record, with e-commerce accounting for 79% of them.

One detail is worth flagging to anyone proposing a quick fix. Roughly a fifth of sued companies already had a third-party accessibility overlay or widget installed when the complaint arrived. Overlays adjust font size and contrast on top of a page's existing markup, but they cannot restructure a broken DOM, fix a missing label, or add keyboard support to a custom component that never had any. The FTC settled with overlay vendor accessiBe for $1 million in January 2025 over claims that its widget delivered full WCAG compliance, and no US court has accepted an overlay as evidence of ADA compliance.

For teams building for US state and local government, or contracting with one, the relevant deadline moved this year too. The Department of Justice's Title II rule, which requires WCAG 2.1 AA conformance, was pushed from April 2026 to April 26, 2027 for entities serving 50,000 or more people, and April 26, 2028 for smaller entities and special districts. An extra year on the calendar is not a reason to deprioritize the work. It is time to do it properly instead of bolting on a widget the week before the original deadline.


A rollout plan that does not require a quarter of standstill

Treating accessibility as a single giant remediation project is how it ends up permanently at the bottom of the backlog. A rollout that actually ships looks more like this:

  1. Run a baseline scan this week. Point axe-core's CLI or Playwright integration at your five highest-traffic pages. This tells you your actual error count, not an estimate.

  2. Fix the six WebAIM categories first. Contrast, alt text, form labels, empty links, empty buttons, document language. These are mechanical fixes with no design debate attached, and they alone address the bulk of what shows up in a typical audit.

  3. Add the CI gate before you add more components. A gate that only checks new code stops the problem from growing while you work through the backlog.

  4. Audit your three most complex interactive components by hand. Usually a modal, a data table, and a multi-step form. These are where the real engineering work and the real ARIA patterns live.

  5. Instrument it. If you already route product analytics through something like PostHog, a feature flag that surfaces keyboard-only sessions or screen reader user agents gives you real usage data instead of guesses about who hits your edge cases. That same data and analytics layer is also where you will eventually want to track completion rates for keyboard-only checkout flows against your mouse-driven baseline.

None of these steps require stopping other work. They require making accessibility a normal part of code review instead of a special project that gets scheduled and then quietly dropped.

One more connection worth making. Several of the mechanical fixes above, image formats, layout stability, font loading, overlap directly with the Core Web Vitals work most teams are already doing for performance. A properly sized, properly compressed image with real alt text helps both your Largest Contentful Paint and a screen reader user in the same commit.


Frequently asked questions

What is the difference between WCAG 2.1 and WCAG 2.2? WCAG 2.2 keeps every success criterion from 2.1 and adds nine new ones, covering focus visibility, pointer target size, dragging alternatives, consistent help placement, reduced redundant form entry, and accessible authentication. It also removes one criterion, 4.1.1 Parsing, which was about HTML validity and is now largely redundant with how modern browsers parse markup.

Can axe-core alone make my site accessible? No. Axe-core's own documentation estimates it catches around 57% of WCAG issues automatically. It is excellent at catching missing labels, contrast failures, and invalid ARIA, and it cannot judge whether your alt text is meaningful, whether your tab order makes sense, or whether a drag interaction has a working alternative. Treat it as the first layer of a testing strategy, not the whole strategy.

Do accessibility overlay widgets satisfy ADA requirements? No court has accepted an overlay as evidence of compliance, and roughly 20% of companies sued over web accessibility in 2026 already had one installed. Overlays sit on top of a page's existing code and cannot fix a broken DOM structure or add real keyboard support to a component that never had it.

What is the minimum color contrast ratio for WCAG AA? Normal body text needs a 4.5:1 contrast ratio against its background. Large text, 18pt or 14pt bold and above, needs 3:1. WCAG 2.2 adds a separate 3:1 requirement specifically for the contrast between a focus indicator's focused and unfocused states.

How big does a button need to be under WCAG 2.2? At least 24 by 24 CSS pixels, or spaced so that a 24px circle centered on it does not overlap another target. Icon-only buttons are the most common place this gets missed, since a 16px icon with no padding falls well short.

Does accessible design slow down development? Building it in from the start, semantic HTML, labeled form fields, real focus management, costs very little extra time. Retrofitting it after years of div-based components and outline: none costs considerably more. The WebAIM data backs this up directly. The same six low-effort issues have topped the error list for seven consecutive years because they were never addressed at build time.


Final verdict

Treat accessibility as a scanner problem and you will ship a page that passes CI and still fails the person it was built for. The four WCAG 2.2 criteria above, a small set of component patterns built correctly once, and axe-core wired into Playwright close most of the gap inside a sprint or two. That is the easy 57%.

The rest only comes from an engineer who has actually tabbed through the product, or opened it with a screen reader, and noticed where it breaks. No tool ships that discipline for you, and no overlay fakes it convincingly enough to survive either a real user or a lawsuit.

If there is one line to take away: build the four WCAG 2.2 basics into your component library now, gate CI on axe-core today, and spend the thirty minutes a sprint on manual testing that no scanner can do for you. Everything else in this piece is detail in service of that.

Questions

Frequently asked questions

What is the difference between WCAG 2.1 and WCAG 2.2?

WCAG 2.2 keeps every success criterion from 2.1 and adds nine new ones, covering focus visibility, pointer target size, dragging alternatives, consistent help placement, reduced redundant form entry, and accessible authentication. It also removes one criterion, 4.1.1 Parsing, which was about HTML validity and is now largely redundant with how modern browsers parse markup.

Can axe-core alone make my site accessible?

No. Axe-core's own documentation estimates it catches around 57% of WCAG issues automatically. It is excellent at catching missing labels, contrast failures, and invalid ARIA, and it cannot judge whether your alt text is meaningful, whether your tab order makes sense, or whether a drag interaction has a working alternative. Treat it as the first layer of a testing strategy, not the whole strategy.

Do accessibility overlay widgets satisfy ADA requirements?

No court has accepted an overlay as evidence of compliance, and roughly 20% of companies sued over web accessibility in 2026 already had one installed. Overlays sit on top of a page's existing code and cannot fix a broken DOM structure or add real keyboard support to a component that never had it.

What is the minimum color contrast ratio for WCAG AA?

Normal body text needs a 4.5:1 contrast ratio against its background. Large text, 18pt or 14pt bold and above, needs 3:1. WCAG 2.2 adds a separate 3:1 requirement specifically for the contrast between a focus indicator's focused and unfocused states.

How big does a button need to be under WCAG 2.2?

At least 24 by 24 CSS pixels, or spaced so that a 24px circle centered on it does not overlap another target. Icon-only buttons are the most common place this gets missed, since a 16px icon with no padding falls well short.

Does accessible design slow down development?

Building it in from the start, semantic HTML, labeled form fields, real focus management, costs very little extra time. Retrofitting it after years of div-based components and outline: none costs considerably more. The WebAIM data backs this up directly. The same six low-effort issues have topped the error list for seven consecutive years because they were never addressed at build time.

WebTechOS accepts no payment for coverage, placement or scores. Where a piece references pricing, it reflects published list rates at the date shown.