Skip to main content
1:1 mock interviews with Sumit, scored on a real hiring rubric.Book a slot →

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.

Sumit KumarUpdated Oct 12, 20267 min readHTML
Web Accessibility (a11y) Interview Questions: WCAG, ARIA, Keyboard and Screen Readers

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.

The four WCAG accessibility principles, POUR: perceivable content with alt text and contrast, operable interfaces with keyboard access and focus, understandable labels and errors, and robust markup using semantic HTML and correct ARIA

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:

PrincipleMeaningExamples
PerceivableUsers can sense the contentAlt text, captions, sufficient contrast, not relying on colour alone
OperableUsers can operate the interfaceKeyboard access, visible focus, no keyboard traps, enough time
UnderstandableContent and behaviour are clearLabels, clear error messages, consistent navigation, page language
RobustWorks with assistive technologiesValid semantic HTML, correct names, roles and states

Q2. Why is semantic HTML the foundation of accessibility?#

HTML
<!-- 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?#

HTML
<!-- 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.

HTML
<!-- 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?#

AttributeProvidesUse when
aria-labelAccessible name as a stringNo visible text label exists (icon buttons)
aria-labelledbyName taken from other elements' textA visible heading or text already labels it
aria-describedbyExtra description, read after the nameHints, 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.

CSS
/* Never remove focus outlines without a replacement */
button:focus-visible, a:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}
tabindexEffect
0Element joins the natural tab order (for custom widgets)
-1Not 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?#

HTML
<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>
JavaScript
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 focus

Answer: 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:

HTML
<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?#

HTML
<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 with for/id; placeholders are not labels.
  • Group related controls with fieldset and legend.
  • Error messages are specific, linked with aria-describedby, and not shown by colour alone.
  • Use autocomplete and correct input types to reduce typing.

Q10. What are the colour contrast requirements?#

ContentWCAG AA minimum ratio
Normal text4.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?#

HTML
<!-- 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>
CSS
.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?#

  1. Automated tools: axe DevTools, Lighthouse, WAVE, and eslint-plugin-jsx-a11y in the editor. Add jest-axe or @axe-core/playwright to tests. Automated checks catch roughly a third of issues.
  2. Keyboard-only testing: unplug the mouse; can you reach and operate everything, and can you always see focus?
  3. Screen reader testing: NVDA or JAWS on Windows, VoiceOver on macOS and iOS, TalkBack on Android.
  4. Zoom and reflow: 200% text and 400% zoom at 1280px width without loss of content.
  5. Real users: usability testing with people with disabilities finds what tools miss.
JavaScript
// 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#

TopicRemember
TargetWCAG 2.2 level AA
PrinciplesPerceivable, Operable, Understandable, Robust
First choiceNative semantic HTML over ARIA
Decorative imagealt=""
FocusAlways visible; tabindex="0" or -1, never positive
ModalTrap focus, Esc closes, return focus to trigger
Contrast4.5:1 text, 3:1 large text and UI
Dynamic updatesaria-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.