Skip to content

No. 27Frontend8 min read2,157 words

Web accessibility for developers: the 80/20 guide

Web accessibility for developers, the 80/20: the few habits that fix most real bugs, from semantic HTML and labels to focus, contrast and WCAG 2.2 basics.

Written by
Lazy Devs
Published
Updated
Sources
Cited inline

Key takeaways ยท 05

The short version

  1. 01Six error types (low contrast text, missing alt text, missing form labels, empty links, empty buttons and missing page language) account for the vast majority of automatically detected accessibility errors on the web, and all six are cheap to fix.
  2. 02Use native HTML elements first. A real button or link gives you focus, keyboard support, a role and an accessible name for free; ARIA is for the gaps native HTML cannot fill.
  3. 03Every interactive element must be reachable and operable with a keyboard, with a visible focus indicator. Never remove outlines without replacing them, and use :focus-visible.
  4. 04Target WCAG 2.2 level AA: 4.5:1 contrast for normal text, 3:1 for large text, and interactive targets of at least 24 by 24 CSS pixels or with enough spacing around them.
  5. 05Automated tools such as axe catch only part of the problem. Pair them with a five-minute keyboard test and a quick screen reader pass on every key flow.
On this page ยท 10

The 80/20 of web accessibility for developers is a short list: use native HTML elements, label every input, make everything work with a keyboard, keep focus visible, and meet contrast minimums. Those habits fix most of the real-world bugs people hit, and they are things you should be doing anyway because they make your code simpler and easier to test.

Most accessibility advice reads like a 400-item checklist that nobody finishes. This is the opposite: the parts that matter, the parts you can ship this week, and the parts you can stop worrying about. It is the baseline we build into every project, and the first thing we check when we take over an existing frontend.

Why accessibility is worth your time (the honest version)

Two reasons, no guilt trip. First, a real share of your users navigate with a keyboard, a screen reader, voice control, switch devices or simply a zoomed-in browser. When a flow is broken for them, they leave, and they rarely tell you why. Second, the things that make a page accessible, semantic structure, real labels and predictable focus, are the same things that make it testable, maintainable and easier for search engines to understand.

There is also a legal dimension, and it has grown. In the US, the Department of Justice has published guidance on web accessibility under the ADA and a rule adopting WCAG 2.1 AA for state and local government websites. In the EU, the European Accessibility Act applies to many consumer-facing products and services, including e-commerce, from June 2025. This is engineering guidance, not legal advice: check your specific obligations with a lawyer. But for most teams, the technical target is the same either way: WCAG 2.2 at level AA.

The six errors that make up most accessibility failures

You do not need to guess where to start. WebAIM's annual analysis of the top million home pages finds the same six error types year after year, and together they make up almost all automatically detected errors:

ErrorWhat it meansThe fix
Low contrast textText too faint against its backgroundMeet 4.5:1 for normal text, 3:1 for large text
Missing alt textImages with no text alternativeDescribe meaningful images; alt="" for decorative ones
Missing form labelsInputs with no programmatic labelA real label tied to every input
Empty linksLinks with no accessible text, often icon linksVisible text or an accessible name
Empty buttonsIcon-only buttons with no namearia-label or visually hidden text
Missing document languageNo lang on the html elementSet lang="en" (or your language) once in the root layout

Every one of these is a one-line fix, and most can be enforced in a shared component so they never come back. If you only do one thing after reading this post, fix these six.

Start with semantic HTML

The single biggest lever is using the right element. A div with a click handler is invisible to assistive technology. A button gets keyboard focus, fires on Enter and Space, announces its role, and works with voice control, all for free.

// Don't reinvent a button
<div className="btn" onClick={handleSave}>Save</div>
 
// Do use the element the browser already ships
<button type="button" onClick={handleSave}>Save</button>

The same rule applies across the page:

  • Landmarks: use header, nav, main, aside and footer so screen reader users can jump between regions.
  • Headings: one h1 per page, and do not skip levels because a smaller heading looked nicer. Style with CSS, structure with tags.
  • Lists: use ul and ol for lists, so screen readers announce "list, 5 items".
  • Links versus buttons: use a for navigation and button for actions. A link that triggers a mutation and a button that navigates both break expectations.
  • Tables: use real table markup with th for tabular data, not a grid of divs.

If you find yourself reaching for role="button", tabIndex, and a keydown handler, stop. You are rebuilding a button badly. The W3C's guidance on using ARIA puts it as the first rule: if a native element with the semantics you need exists, use it instead of adding ARIA to something else.

Labels and accessible names: the thing everyone skips

Every input needs a label that is programmatically associated with it, not just a placeholder. Placeholders disappear when you type, usually fail contrast, and are not reliably announced. Associate a real label with htmlFor matching the input id.

export function EmailField({ value, onChange }: {
  value: string;
  onChange: (v: string) => void;
}) {
  return (
    <div>
      <label htmlFor="email">Work email</label>
      <input
        id="email"
        name="email"
        type="email"
        autoComplete="email"
        value={value}
        onChange={(e) => onChange(e.target.value)}
        aria-describedby="email-hint"
      />
      <p id="email-hint">We only use this to send your receipt.</p>
    </div>
  );
}

The autoComplete attribute is worth a mention: it lets browsers and password managers fill fields correctly, which helps people with motor and memory impairments, and WCAG 2.2 adds requirements around not making people re-enter information they already gave you.

For icon-only buttons (the menu, the close X, the search magnifier), there is no visible text, so give them an accessible name:

<button type="button" aria-label="Close dialog" onClick={onClose}>
  <XIcon aria-hidden="true" />
</button>

Note aria-hidden="true" on the icon. Decorative SVGs should be hidden from the accessibility tree so the button announces "Close dialog, button" and not something confusing about an image.

Images follow the same logic. Meaningful images need alt text describing what they communicate in context; decorative ones get an empty alt="". The W3C alt text decision tree settles most cases in a minute, and good alt text also helps image search, as we cover in our image optimization guide.

Keyboard support and visible focus are not optional

Tab through your own page. Right now, with your mouse hand in your lap. Can you reach every interactive element? Can you tell where focus is? Can you operate the menu, the modal and the date picker without a pointer? If not, some of your users cannot use the feature at all.

Three failure modes dominate.

1. Invisible focus

Someone added outline: none in a CSS reset and never replaced it. Do not remove focus indicators. If the default ring clashes with the design, restyle it, and use :focus-visible so the ring shows for keyboard users without flashing on every mouse click.

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

WCAG 2.2 also added a rule that the focused element must not be entirely hidden behind other content, such as a sticky header or cookie banner. Add scroll-padding-top equal to your sticky header height and the browser will keep focused elements in view.

2. Keyboard traps in custom components

Usually in a custom modal. When a dialog opens, focus should move into it, stay inside it while it is open, return to the trigger when it closes, and Escape should close it. That is enough fiddly logic that you should not hand-write it. Use the native dialog element with showModal(), which handles focus containment and Escape for you, or a vetted primitive library. The ARIA Authoring Practices Guide documents the expected keyboard behaviour for menus, tabs, comboboxes and other widgets if you must build one.

3. Broken focus order

If the visual order and the DOM order disagree (often from CSS grid reordering or absolutely positioned elements), Tab jumps around the page unpredictably. Keep the DOM in reading order and avoid positive tabIndex values entirely.

Color contrast, target size and not relying on color alone

Text needs enough contrast against its background: 4.5:1 for normal text and 3:1 for large text. That trendy light-grey-on-white body copy probably fails. Browser DevTools flag contrast issues directly in the inspector. Fix it in your design tokens once rather than page by page.

WCAG 2.2 also introduced a minimum target size: interactive targets should be at least 24 by 24 CSS pixels, or spaced so a 24px circle around each does not overlap its neighbours. Tiny icon buttons and tightly packed links in footers are the usual failures.

Finally, never use color as the only signal. A field that turns red on error means nothing to a colour-blind user or a screen reader. Pair colour with text and a programmatic association:

<input
  id="password"
  type="password"
  aria-invalid={hasError}
  aria-describedby="password-error"
/>
<p id="password-error" role="alert">
  {hasError ? "Password must be at least 12 characters." : ""}
</p>

aria-describedby ties the message to the input so it is read when the field gets focus, and keeping the role="alert" container mounted while only its text changes makes the announcement reliable when the error appears.

Dynamic content and the single-page app problem

Single-page apps break two assumptions screen readers rely on.

Route changes. When you navigate client-side, the URL changes but the page does not reload, so nothing announces the new view. Next.js includes a route announcer that reads the page title (falling back to the h1) on client-side navigation, which is one more reason every page needs a unique, descriptive title. For in-page transitions you build yourself, such as multi-step forms, move focus to the new step's heading.

Live updates. A toast, a "saved" confirmation, or a results count that changes as you type will be missed unless it is in a live region. Render the container once, empty, with aria-live="polite", and update its text later. Mounting the region and its text in the same render can mean the announcement never happens.

// Mounted once, empty. Updating `message` later triggers the announcement.
<div aria-live="polite" className="sr-only">
  {message}
</div>

Also respect motion preferences. Wrap large animations and parallax in a prefers-reduced-motion media query so people who get motion sickness can still use the page.

How to test accessibility without a dedicated team

You do not need an audit phase bolted on at the end. You need three quick checks built into normal work:

  1. Automated scanning. Run axe-core in your end-to-end tests (Playwright has a documented integration) and keep the jsx-a11y lint rules that Next.js's ESLint config includes. Automated tools catch mechanical errors such as missing labels and contrast. They cannot tell you whether the focus order makes sense or whether your alt text is useful, so treat a clean scan as necessary, not sufficient.
  2. A keyboard pass. Five minutes per key flow: sign up, checkout, the main form. Tab, Shift+Tab, Enter, Space, Escape and the arrow keys.
  3. A screen reader pass. VoiceOver on macOS and iOS, or NVDA on Windows, on your most important pages. Listen to whether headings, labels and buttons make sense out of context.
CheckCatchesMissesEffort
Lint rules (jsx-a11y)Missing alt, invalid ARIA, click handlers on static elementsAnything about runtime behaviourNear zero, runs on save
axe in end-to-end testsContrast, labels, names, landmarks, duplicate IDsFocus order, meaning, usabilityLow, once set up
Keyboard passTraps, invisible focus, unreachable controlsScreen reader announcementsMinutes per flow
Screen reader passConfusing names, missing announcements, bad structureVisual issuesLonger; do it on key flows

What you can safely skip, for now

You do not need to memorize every ARIA attribute: native elements with the right semantics beat a div with five aria-* props every time. You do not need a perfect Lighthouse accessibility score; it is a useful smoke test, not a certificate. And you should not buy an accessibility overlay widget: it cannot fix the underlying markup, and it often gets in the way of the assistive technology people already use.

What you should do is build the habits into the components you write once: your shared Button, Input, Dialog and Link. Get those right in a design system and every page that uses them inherits the fixes without anyone thinking about it again.

Your first hour on accessibility

Spend it on the cheap, high-yield work:

  1. Set lang on the html element.
  2. Replace clickable divs with button and a.
  3. Give every input a real label and every icon button an accessible name.
  4. Restore visible focus with :focus-visible.
  5. Check contrast in your design tokens.
  6. Tab through your three most important flows and fix what you cannot reach.

That handful of habits clears most real-world accessibility bugs, and it makes your React codebase cleaner as a side effect. The thorough audit can come later.

If you are planning a website redesign or need a key flow to work for everyone before a deadline, accessibility is built into how we work. Tell us what you are building.

When you are ready for the thorough audit, work through our free accessibility audit checklist, mapped to every WCAG 2.2 AA criterion. If you sell to EU customers, read what the European Accessibility Act means for websites, and for the numbers behind all of this, see our web accessibility statistics.

FAQ ยท 05 questions

Frequently asked questions

What WCAG level should my website meet?

Aim for WCAG 2.2 level AA. It is the level most laws, procurement rules and accessibility statements reference, and it is achievable for normal product teams. Level AAA is useful as a guide for specific content but is not expected as a whole-site target.

Is my website legally required to be accessible?

It depends on where you operate and who you serve. In the US, the Department of Justice applies the ADA to the web and has set WCAG 2.1 AA as the technical standard for state and local government sites. In the EU, the European Accessibility Act applies to many consumer-facing products and services from June 2025. This is engineering guidance, not legal advice, so check your obligations with a lawyer.

Can accessibility overlays or widgets make my site compliant?

No. Overlays add a toolbar on top of the page but cannot fix missing labels, broken keyboard support or poor structure in the underlying code, and they can interfere with the assistive technology people already use. The reliable fix is accessible markup in your components.

How do I test my website for accessibility?

Combine three checks. Run an automated scanner such as axe or Lighthouse to catch mechanical errors, tab through every key flow with the keyboard only, and use a screen reader such as VoiceOver or NVDA on the most important pages. Add automated checks to CI so regressions are caught before release.

Does accessibility help SEO?

Partly. Many accessibility practices, such as descriptive headings, alt text on meaningful images, real links and a clear page structure, also make content easier for search engines to understand. Accessibility is not a ranking factor on its own, but the overlap is large.

Related service

Web App Development

Production React and Next.js apps, built to last.

Learn more

Next step

Want this built right?

This is the work we do every day. Tell us what you are building and we will show you exactly how we would ship it.

First reply
Within 1 business day
Typical start
1โ€“2 weeks
Pricing
Fixed price per phase
You own
All code and accounts