Tech Interview RoomStudy guides

Browser & Performance

How do you make a web app accessible? Which WCAG rules come up most in interviews?

Intermediate · 2 min read · Lesson 5 of 8 in Browser & Performance

WCAG 2.2 level AA is the usual legal and contractual target (and is required by the European Accessibility Act from June 2025 for many services). The principles are POUR: Perceivable, Operable, Understandable, Robust.

The checklist that catches most issues

  1. Semantic HTML: real buttons, links, headings, landmarks, lists and tables.
  2. Keyboard: everything works with Tab/Shift+Tab/Enter/Space/Escape/arrow keys, in a logical order, with visible focus (never outline: none without a replacement; use :focus-visible).
  3. Labels: every input has a <label>; icon-only buttons get aria-label.
  4. Text alternatives: meaningful alt on images, captions on video.
  5. Colour contrast: at least 4.5:1 for normal text, 3:1 for large text and UI parts; never rely on colour alone (add icons or text).
  6. Focus management in SPAs: move focus to the new page's heading after route changes; trap focus inside modals and return it on close (native <dialog> does this).
  7. Live regions: announce async results and errors with role="status" / aria-live="polite" or role="alert".
  8. Motion: respect prefers-reduced-motion; no auto-playing content without a pause.
  9. Zoom and reflow: works at 200% zoom and 320px width; target size at least 24×24 CSS px (WCAG 2.2).

ARIA rules

Prefer native elements. If you build a custom widget (tabs, combobox, menu), follow the ARIA Authoring Practices patterns for roles, states (aria-expanded, aria-selected) and keyboard handling. Wrong ARIA is worse than none.

Example

jsx
function Disclosure({ title, children }) {
  const [open, setOpen] = useState(false);
  const id = useId();
  return (
    <section>
      <h3>
        <button aria-expanded={open} aria-controls={id} onClick={() => setOpen(o => !o)}>
          {title}
        </button>
      </h3>
      <div id={id} hidden={!open}>{children}</div>
    </section>
  );
}

function SaveStatus({ status }) {
  return <p role="status" aria-live="polite">{status === 'saved' ? 'All changes saved' : ''}</p>;
}

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

Follow-up questions interviewers ask

Try answering each one before you open it.

How do you build an accessible modal?

Use <dialog> with showModal(): it renders in the top layer, makes the rest of the page inert, closes on Escape and handles focus. Give it a heading referenced by aria-labelledby, put initial focus on the first meaningful control, and return focus to the trigger when it closes. With a custom div, you must add role="dialog", aria-modal="true", a focus trap and inert on the background yourself.