How do you make a web app accessible? Which WCAG rules come up most in interviews?
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
- Semantic HTML: real buttons, links, headings, landmarks, lists and tables.
- Keyboard: everything works with Tab/Shift+Tab/Enter/Space/Escape/arrow keys, in a logical order, with visible focus (never
outline: nonewithout a replacement; use:focus-visible). - Labels: every input has a
<label>; icon-only buttons getaria-label. - Text alternatives: meaningful
alton images, captions on video. - 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).
- 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). - Live regions: announce async results and errors with
role="status"/aria-live="polite"orrole="alert". - Motion: respect
prefers-reduced-motion; no auto-playing content without a pause. - 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
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.