Web Accessibility (a11y) Interview Questions: WCAG, ARIA, Keyboard and Screen Readers
12 web accessibility interview questions with code: WCAG and POUR, semantic HTML, alt text, ARIA rules, keyboard navigation and focus management, accessible forms, colour contrast, accessible modals, live regions, skip links and how to test accessibility.
Accessibility (often written a11y) means people with disabilities can perceive, understand, navigate and interact with your site, whether they use a screen reader, keyboard, voice control, magnification or captions. It's also a legal requirement in many countries. These 12 web accessibility interview questions cover what frontend interviewers ask, with practical code.
Standards and semantics#
Q1. What is WCAG, and what does POUR stand for?#
Answer: the Web Content Accessibility Guidelines (WCAG) from the W3C are the standard most laws reference. Version 2.2 is current. Success criteria have three conformance levels: A (minimum), AA (the usual legal and business target) and AAA (enhanced). They're organised under four principles, POUR:
| Principle | Meaning | Examples |
|---|---|---|
| Perceivable | Users can sense the content | Alt text, captions, sufficient contrast, not relying on colour alone |
| Operable | Users can operate the interface | Keyboard access, visible focus, no keyboard traps, enough time |
| Understandable | Content and behaviour are clear | Labels, clear error messages, consistent navigation, page language |
| Robust | Works with assistive technologies | Valid semantic HTML, correct names, roles and states |
Q2. Why is semantic HTML the foundation of accessibility?#
<!-- Inaccessible: no role, not focusable, no keyboard support -->
<div class="btn" onclick="save()">Save</div>
<!-- Accessible for free: role "button", focusable, Enter/Space work -->
<button type="button" onclick="save()">Save</button>
<!-- Landmarks let screen reader users jump between regions -->
<header>...</header>
<nav aria-label="Main">...</nav>
<main>
<h1>Order history</h1>
<section aria-labelledby="recent"><h2 id="recent">Recent orders</h2>...</section>
</main>
<footer>...</footer>Answer: native elements come with built-in roles, keyboard behaviour and states that assistive technology understands. Landmarks (header, nav, main, footer) and a logical heading hierarchy (one h1, no skipped levels) let screen reader users navigate quickly. Use <a> for navigation and <button> for actions. More HTML basics: HTML interview questions for freshers.
Q3. How do you write good alt text?#
<!-- Informative image: describe its meaning in context -->
<img src="chart.png" alt="Sales grew 40% from January to June" />
<!-- Functional image (inside a link or button): describe the action -->
<a href="/"><img src="logo.svg" alt="Jiocoder home" /></a>
<!-- Decorative image: empty alt so screen readers skip it -->
<img src="divider.svg" alt="" />
<!-- Icon button: the button needs an accessible name -->
<button aria-label="Close dialog"><svg aria-hidden="true">...</svg></button>Answer: alt text should convey the purpose of the image in that context, concisely, without "image of". Decorative images get alt="" (not a missing alt, which makes some screen readers read the file name). Complex images like charts may need a longer description nearby.
ARIA#
Q4. What is ARIA, and what is the first rule of ARIA?#
Answer: ARIA (Accessible Rich Internet Applications) is a set of attributes that add roles, states and properties to elements for assistive technology. It changes only what's announced, not behaviour: role="button" doesn't make a div focusable or respond to Enter.
The first rule of ARIA: if a native HTML element with the semantics and behaviour you need exists, use it instead of adding ARIA. "No ARIA is better than bad ARIA"; incorrect ARIA often makes things worse.
<!-- Common, useful ARIA -->
<button aria-expanded="false" aria-controls="menu">Menu</button>
<ul id="menu" hidden>...</ul>
<input id="email" aria-describedby="email-hint" aria-invalid="true" />
<p id="email-hint">We'll never share your email.</p>
<nav aria-label="Breadcrumb">...</nav>
<span aria-hidden="true">★</span>Q5. What is the difference between aria-label, aria-labelledby and aria-describedby?#
| Attribute | Provides | Use when |
|---|---|---|
aria-label | Accessible name as a string | No visible text label exists (icon buttons) |
aria-labelledby | Name taken from other elements' text | A visible heading or text already labels it |
aria-describedby | Extra description, read after the name | Hints, format requirements, error messages |
Prefer visible labels: they help everyone, including voice control users who say "click Save". If the visible label and aria-label differ, voice users may not be able to activate the control.
Keyboard and focus#
Q6. How do you make an interface keyboard accessible? What does tabindex do?#
Answer: everything that works with a mouse must work with a keyboard: Tab and Shift+Tab to move, Enter and Space to activate, arrow keys within widgets like menus, tabs and listboxes, and Escape to close. Focus order must follow a logical reading order, and focus must always be visible.
/* Never remove focus outlines without a replacement */
button:focus-visible, a:focus-visible {
outline: 3px solid #2563eb;
outline-offset: 2px;
}tabindex | Effect |
|---|---|
0 | Element joins the natural tab order (for custom widgets) |
-1 | Not in the tab order, but focusable with element.focus() (headings, modals, error summaries) |
| Positive (1, 2...) | Forces an order; avoid, it breaks the natural flow |
Q7. How do you build an accessible modal dialog?#
<dialog id="confirm" aria-labelledby="confirm-title">
<h2 id="confirm-title">Delete project?</h2>
<p>This can't be undone.</p>
<button id="cancel">Cancel</button>
<button id="delete">Delete</button>
</dialog>const dialog = document.getElementById("confirm");
let opener;
function openDialog(event) {
opener = event.currentTarget;
dialog.showModal(); // traps focus, makes the page behind inert, Esc closes
}
dialog.addEventListener("close", () => opener?.focus()); // return focusAnswer: requirements are: an accessible name, focus moves into the dialog when it opens, focus is trapped inside, the background is inert, Escape closes it, and focus returns to the trigger on close. The native <dialog> element with showModal() handles most of this. In custom implementations use role="dialog", aria-modal="true" and the inert attribute on the rest of the page.
Q8. How do you manage focus in single-page applications?#
Answer: in a SPA, route changes don't reload the page, so screen reader users may not know the content changed. After navigation, move focus to the new page's h1 (with tabindex="-1") or a wrapper, and update document.title. Also manage focus after deleting an item (move to the next item or the list heading) and after submitting a form with errors (move to an error summary). Provide a skip link as the first focusable element:
<a class="skip-link" href="#main">Skip to main content</a>
<main id="main" tabindex="-1">...</main>Forms, colour and dynamic content#
Q9. How do you make forms accessible?#
<form novalidate>
<label for="phone">Phone number</label>
<input id="phone" type="tel" autocomplete="tel" required
aria-describedby="phone-hint phone-error" aria-invalid="true" />
<p id="phone-hint">10 digits, no spaces</p>
<p id="phone-error" class="error">Enter a 10-digit phone number</p>
<fieldset>
<legend>Delivery speed</legend>
<label><input type="radio" name="speed" value="standard" /> Standard</label>
<label><input type="radio" name="speed" value="express" /> Express</label>
</fieldset>
</form>- Every input has a visible
<label>connected withfor/id; placeholders are not labels. - Group related controls with
fieldsetandlegend. - Error messages are specific, linked with
aria-describedby, and not shown by colour alone. - Use
autocompleteand correct input types to reduce typing.
Q10. What are the colour contrast requirements?#
| Content | WCAG AA minimum ratio |
|---|---|
| Normal text | 4.5 : 1 |
| Large text (24px, or 18.66px bold) | 3 : 1 |
| UI components and graphics (input borders, icons, focus rings) | 3 : 1 |
Answer: also, never use colour as the only way to convey information. A red border for an error should come with an icon and text; a chart line should have labels or patterns. Check contrast with DevTools' colour picker or a contrast checker, and respect user settings like prefers-reduced-motion and forced-colours (Windows high-contrast) mode.
Q11. How do screen readers learn about dynamic updates?#
<!-- Polite: announced when the user is idle (toasts, "3 results found") -->
<div aria-live="polite" class="sr-only" id="status"></div>
<!-- Assertive / alert: interrupts (urgent errors only) -->
<div role="alert">Payment failed. Check your card details.</div>.sr-only {
position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}Answer: live regions announce content changes without moving focus. The region must exist in the DOM before its content changes. Use polite for most updates and assertive or role="alert" sparingly. The .sr-only class hides text visually while keeping it available to screen readers (unlike display: none, which hides it from everyone).
Testing#
Q12. How do you test a website for accessibility?#
- Automated tools: axe DevTools, Lighthouse, WAVE, and
eslint-plugin-jsx-a11yin the editor. Addjest-axeor@axe-core/playwrightto tests. Automated checks catch roughly a third of issues. - Keyboard-only testing: unplug the mouse; can you reach and operate everything, and can you always see focus?
- Screen reader testing: NVDA or JAWS on Windows, VoiceOver on macOS and iOS, TalkBack on Android.
- Zoom and reflow: 200% text and 400% zoom at 1280px width without loss of content.
- Real users: usability testing with people with disabilities finds what tools miss.
// Example: accessibility assertion in a Playwright test
import AxeBuilder from "@axe-core/playwright";
test("checkout page has no detectable a11y violations", async ({ page }) => {
await page.goto("/checkout");
const results = await new AxeBuilder({ page }).analyze();
expect(results.violations).toEqual([]);
});Quick revision#
| Topic | Remember |
|---|---|
| Target | WCAG 2.2 level AA |
| Principles | Perceivable, Operable, Understandable, Robust |
| First choice | Native semantic HTML over ARIA |
| Decorative image | alt="" |
| Focus | Always visible; tabindex="0" or -1, never positive |
| Modal | Trap focus, Esc closes, return focus to trigger |
| Contrast | 4.5:1 text, 3:1 large text and UI |
| Dynamic updates | aria-live="polite" or role="alert" |
Related: HTML and CSS interview questions and frontend testing interview questions.
Key takeaways#
- Aim for WCAG 2.2 AA, organised by the POUR principles.
- Semantic HTML gives roles, focus and keyboard behaviour for free; use ARIA only to fill gaps.
- Everything must work by keyboard with a visible focus indicator and sensible focus management.
- Label every form control, write meaningful alt text, meet contrast ratios and don't rely on colour alone.
- Combine automated tools with keyboard, screen reader and zoom testing.