Accessibility Middle cheat sheet: interview answers
Every question of this level with its correct answer and explanation, on one page for a quick review before the interview.
1. What is the accessibility tree?
Correct answer: A browser structure of roles, names and states built from the DOM
Assistive technologies read this tree through platform APIs, not the DOM directly. Chrome and Firefox DevTools let you inspect it for any element.
2. Which source usually wins when computing an element's accessible name?
Correct answer:
aria-labelledby, thenaria-label, then native labelling and contentThe computation has a defined order.
aria-labelledbyoverrides everything, so a stale reference can silently replace a good visible label.3. What is the difference between
aria-labelledbyandaria-describedby?Correct answer: The first sets the name; the second adds a supplementary description
The name says what a control is and is always announced. The description adds details such as format hints, and users can configure whether they hear it.
4. Why prefer
aria-labelledbypointing at visible text overaria-label?Correct answer: Visible text stays in sync and is translated with the page
aria-labelis easy to forget during updates and browser translation tools may skip it. Reusing visible text keeps one source of truth.5. What is wrong here?
<div aria-label="Order status">Shipped</div>Correct answer:
aria-labelon a genericdivwith no role is not reliably exposedNaming is prohibited on the generic role, so assistive tech may ignore it. Give the element a suitable role or use real text.
6. Why is
<nav role="navigation">unnecessary?Correct answer:
<nav>already has that implicit roleNative elements have implicit roles, so repeating them adds noise.
html-arialists which roles are allowed on each element.7. Why can
<button role="link">be a bad idea?Correct answer: It announces a link but behaves like a button
A role overrides the native semantics without changing behaviour, so users hear one thing and get another. Choose the element that matches the behaviour.
8. Two
<nav>elements on one page: what should you do?Correct answer: Give each a distinct name with
aria-labelScreen readers list landmarks, so "Main navigation" and "Footer links" are useful, while two entries called "navigation" are not.
9. When does a
<section>become a landmark?Correct answer: When it has an accessible name, as a
regionAn unnamed
sectionis ignored as a landmark. Name only significant regions, or the landmark list gets noisy.10. How should a field error be linked to its input?
Correct answer:
aria-invalid="true"plusaria-describedbyto the messageThe state says the value is invalid and the description says why, so the message is read when the field gets focus.
aria-errormessageexists but has weaker support.11. Native
requiredoraria-required: which should you prefer?Correct answer:
required, since it brings both semantics and validationrequiredhas semantics and validation.aria-requiredonly announces. UsingnoValidatewithrequiredalso works for custom error UIs.12. After a failed submit of a long form, what's a good pattern?
Correct answer: Move focus to an error summary with links to the fields
A summary tells users how many errors exist and takes them there. Focus should move to it so keyboard and screen reader users notice.
13. Why validate on blur or submit rather than on each keystroke?
Correct answer: Errors announced mid-typing interrupt and confuse users
Telling users an email is invalid after the first letter is noise, and worse with a screen reader. Validate when they've finished the field.
14. What does
aria-live="polite"do differently fromassertive?Correct answer: It waits for a pause instead of interrupting speech
Use
politefor most status updates.assertiveinterrupts, so keep it for urgent problems like a lost connection.15. Why doesn't injecting a new element with
role="alert"always get announced?Correct answer: Live regions are most reliable when they exist before changing
Assistive tech has to register the region first. Keep an empty container in the DOM and update its text.
16. What is the difference between
role="status"androle="alert"?Correct answer:
statusis polite;alertis assertive and for important messages"3 results found" is a status. "Payment failed" is an alert. Neither moves focus.
17. Why doesn't a React Router or Next.js page change behave like a full page load for a screen reader?
Correct answer: No document load happens, so nothing is announced automatically
Manage it yourself: update the title, move focus to the main heading or announce the change. Next.js has a built-in route announcer.
18. After client-side navigation, where should focus usually go?
Correct answer: To the new page's main heading or container
Otherwise focus stays on a link that may no longer exist, or resets to the body. The heading needs
tabindex="-1"to accept focus.19. A user deletes a list item and focus was on its Delete button. What should happen?
Correct answer: Move focus to a nearby item or the list heading
When the focused element is removed, focus falls back to
body, and keyboard users start over. Decide where it goes.20. Which keyboard behaviour is expected in a tabs widget (
role="tablist")?Correct answer: Tab enters the list; arrow keys switch between tabs
A tablist is one Tab stop, so users can skip it quickly. Arrows move within, and Tab goes on to the panel.
21. What is roving
tabindex?Correct answer: Only the active item has
tabindex="0"; others have-1On arrow keys you swap the values and move focus. Tab then enters the group at the last active item.
22. When is
aria-activedescendantused instead of rovingtabindex?Correct answer: When DOM focus must stay on one element, like a combobox input
The input keeps focus so the user can type, and the attribute points to the highlighted option. You also have to scroll and style that option yourself.
23. Should a site's main navigation use
role="menu"?Correct answer: No, plain links in
navare better; menus are app-style widgetsrole="menu"promises desktop-style behaviour with arrow keys and hides the fact that items are links. A disclosure button with a list of links suits most sites.24. How do you build an accessible dropdown of navigation links?
Correct answer: A button with
aria-expandedthat shows a list of linksThis is the disclosure pattern. It works with touch, keyboard and screen readers without any ARIA menu roles.
25. In an accordion, what should the header contain?
Correct answer: A button inside a heading, with
aria-expandedThe heading keeps the outline and the button handles interaction.
aria-controlscan link it to the panel.26. Which is true of tooltips?
Correct answer: They must appear on focus too and hold only non-essential text
A tooltip is not focusable content. If it contains interactive elements, you need a popover or dialog.
27. Hover content must meet three conditions under WCAG 1.4.13. Which are they?
Correct answer: Dismissible, hoverable and persistent
Esc should close it without moving the pointer, the pointer can move onto it, and it stays until the user is done.
28. How do you make a toggle button's state available to assistive tech?
Correct answer:
aria-pressed="true"or"false"with a stable labelPick one: state with a stable name ("Mute", pressed) or a label that changes ("Mute" to "Unmute"). Doing both reads as "Unmute, pressed".
29. When should you use
role="switch"rather than a checkbox?Correct answer: For an on/off setting that takes effect immediately
A switch communicates on and off rather than checked. Use a native checkbox as a base when you can.
30. Which attributes does a custom modal need?
Correct answer:
role="dialog",aria-modal="true"and an accessible namearia-labelledbyusually points to the title. Native<dialog>withshowModal()handles most of the rest for you.31. What does the
inertattribute do?Correct answer: Blocks focus and clicks and hides content from assistive tech
Setting
inerton background content is the modern way to keep users in a custom modal. It replaces manualaria-hiddenandtabindexjuggling.32. Why render a custom modal in a React portal?
Correct answer: It escapes parent stacking and makes the background easy to
inertPortals only change where the DOM goes. You still have to manage focus, Esc and semantics. Note that React events bubble through the React tree.
33. A confirm dialog like "Delete project?" should use which role?
Correct answer:
alertdialog, with focus on the least destructive actionalertdialogsignals an interruption that needs a response. Placing initial focus on Cancel avoids accidental deletion.34. A sticky header covers the focused element after tabbing. What fixes it?
Correct answer:
scroll-padding-topon the scrolling containerWCAG 2.2 requires a focused element not to be entirely hidden by author content. Scroll padding keeps it clear of the header.
35. What contrast does WCAG require for a focus indicator or input border?
Correct answer: 3:1 against adjacent colours
Non-text contrast covers UI components and meaningful graphics. An input with a pale grey border may fail even if its text passes.
36. Do disabled controls have to meet contrast requirements?
Correct answer: No, inactive components are exempt
WCAG exempts them, though a very faint button can still confuse users. Consider explaining why the control is unavailable.
37. What is the difference between
disabledandaria-disabled="true"?Correct answer:
aria-disabledkeeps focus and clicks; you must block the actionA
disabledbutton leaves the Tab order, so users can't discover it.aria-disabledlets them reach it and hear why it's unavailable.38. What is forced colors mode?
Correct answer: The OS replaces page colours with a user-chosen palette
Windows Contrast Themes use it. Backgrounds and shadows disappear, so a focus ring made with
box-shadowvanishes. Preferoutline.39. Why is a focus style made only with
box-shadowrisky?Correct answer: It disappears in forced colors mode
outlinesurvives. A common trick isoutline: 2px solid transparent, which becomes visible in forced colors.40. What does the media query
prefers-contrast: moredetect?Correct answer: A user request for higher contrast in the system
Use it to strengthen borders and text colours. It's separate from
forced-colors.41. What does WCAG 1.4.10 Reflow require?
Correct answer: Content fits 320 CSS px wide with no two-way scrolling
That equals 1280px at 400% zoom. Data tables and maps are exempt because they need two dimensions.
42. What does the Text Spacing criterion test?
Correct answer: No content is lost when users raise line and letter spacing
Users may apply their own styles. Fixed-height boxes that clip text are the usual failure.
43. Why shouldn't a site lock itself to portrait orientation?
Correct answer: A mounted device may be fixed in one orientation
People with wheelchair-mounted tablets can't rotate them. Lock only if essential, as in a piano app.
44. What does the Pointer Cancellation criterion ask for?
Correct answer: Actions fire on release, so users can slide away to cancel
Firing on
mousedownmeans an accidental press can't be undone. Nativeclickalready fires on release.45. A kanban board uses drag and drop. What does WCAG 2.2 require?
Correct answer: A single-pointer alternative, like "Move to" buttons
Dragging is hard or impossible for many users. Buttons or a menu also give keyboard users a route, which is a separate requirement.
46. What does the Redundant Entry criterion aim to prevent?
Correct answer: Making users re-enter information in the same process
Pre-fill the shipping address or offer "same as billing". It reduces cognitive load and errors.
47. Why must a login form allow pasting a password?
Correct answer: Password managers and copy-paste avoid a memory test
Accessible Authentication disallows cognitive function tests unless there's an alternative. Blocking paste breaks password managers.
48. What should a session timeout offer?
Correct answer: A warning with a way to extend the session
People may need much longer to complete tasks. WCAG asks you to allow turning off, adjusting or extending limits.
49. A button shows "Search" but has
aria-label="Find products". Why is that a problem?Correct answer: Voice control users saying "click Search" won't hit it
Label in Name requires the accessible name to contain the visible text. Put that text at the start.
50. How should you mark a French phrase in an English page?
Correct answer: Wrap it in an element with
lang="fr"Screen readers switch pronunciation only when told to. This is Language of Parts, at level AA.
51. How do you expose a meaningful inline SVG to assistive tech?
Correct answer:
role="img"with a<title>oraria-labelInline SVGs have no
alt. Decorative ones should getaria-hidden="true"so they're skipped.52. A photo set via CSS
background-imagecarries meaning. What's the issue?Correct answer: There's no text alternative unless you add one
CSS images don't reach the accessibility tree. Use
<img>, or addrole="img"witharia-label.53. What is a good way to expose a sortable table column?
Correct answer: A button in the
th, witharia-sorton the headerThe button gives keyboard access and the attribute announces the sort direction.
54. What does the
<caption>element give a table?Correct answer: An accessible name that describes the table
Screen readers announce it when entering the table, which helps users decide if it's worth reading.
55. Why can
display: blockon a table break accessibility?Correct answer: Browsers may drop the table semantics
Changing
displaycan strip roles, so a responsive table may stop being a table. Add ARIA table roles back, or wrap it in a scrollable region.56. A scrollable code block or table isn't reachable by keyboard. What helps?
Correct answer:
tabindex="0"with a name and a suitable roleKeyboard users need focus to scroll it with arrow keys. Some browsers do this automatically, but not all.
57. How do you mark up breadcrumbs?
Correct answer: A named
navwith a list, andaria-currenton the last itemA name like "Breadcrumb" separates it from other navigation, and separators should be decorative.
58. Why can infinite scroll be a barrier?
Correct answer: The footer becomes unreachable and focus can get lost
Content keeps pushing the footer away. A "Load more" button gives control, and the Feed pattern describes a keyboard model.
59. When "Load more" adds items, where should focus go?
Correct answer: To the first new item, or stay with an announcement
Users must be able to continue reading from where they were. A polite status like "10 more results" helps.
60. What does
aria-busy="true"signal?Correct answer: A region is being updated, so wait with announcements
It's a hint for live regions and similar content. Support varies, so also use a status message for loading states.
61. A virtualized list renders only 20 of 10,000 items. What helps screen readers?
Correct answer:
aria-setsizeandaria-posinseton the itemsThese tell users "item 150 of 10,000" although most items aren't in the DOM. Keyboard focus also has to survive recycling.
62. Why is an auto-rotating carousel a problem?
Correct answer: It moves content users are reading, and needs a pause control
Anything moving for over 5 seconds needs pause, stop or hide. Hovering or focusing should also pause it.
63. Which is true of accessibility overlay widgets?
Correct answer: They don't fix the underlying code and can add new problems
A script can't reliably repair semantics, focus order or
alttext. Many screen reader users dislike them.64. How do screen readers usually read a web page on desktop?
Correct answer: In browse mode, using a virtual cursor; focus mode for fields
In browse mode, keys are shortcuts such as H for headings. In forms, they switch to focus mode so that typing works.
65. Which browser and screen reader pairs are the common test setup?
Correct answer: NVDA with Firefox or Chrome, VoiceOver with Safari
Behaviour depends on the pair, so test the ones your users have. VoiceOver on iOS and TalkBack on Android cover mobile.
66. How do you run axe in Playwright tests?
Correct answer: Use
@axe-core/playwrightto scan the page and assert no violationsIt finds rule-based problems in real pages. You can scan after interactions, for example with a dialog open.
67. What is a limit of
jest-axein jsdom?Correct answer: Without layout, it can't check things such as colour contrast
jsdom doesn't render CSS. Use a real browser for contrast and focus visibility.
68. Roughly how much do automated tools catch?
Correct answer: Only a part of WCAG; manual testing is still needed
Rules can detect a missing
altbut not a misleading one. Automate the cheap checks, then test by hand.69. How does
useIdhelp in React forms?Correct answer: It makes unique, SSR-safe ids for
htmlForand ARIA linksReusable components can't hard-code ids, or two instances would clash. Don't use it for list keys.
70. Why can changing a list
keylose keyboard focus?Correct answer: React remounts the node, destroying the focused element
A new key means a new DOM element, so focus falls to
body. Keep keys stable.71. Why do many teams use headless primitives such as Radix for widgets?
Correct answer: They provide tested focus and keyboard logic, with your styling
Combobox and menu behaviour is hard to get right. You still need good labels, contrast and tests.
72. What is an accessibility statement?
Correct answer: A public page on conformance, known issues and feedback contacts
It shows commitment and gives users a way to report problems. EU public bodies must publish one, and the EAA asks service providers for similar information.
73. Where in the development process is accessibility cheapest to handle?
Correct answer: Early, in design and components, not in a late audit
Colour tokens, focus styles and accessible components spread fixes across the product. Retrofitting costs far more.
74. What does
autocomplete="one-time-code"help with?Correct answer: Offering an SMS code for filling in, so no retyping
It reduces memory and typing effort, in line with Accessible Authentication, and mobile keyboards show the code as a suggestion.
75. Should links that open in a new tab warn users?
Correct answer: Yes, say so in the link text or with a labelled icon
A new tab breaks the Back button, which can disorient screen reader and cognitive users. Avoid it when you can, and warn when you can't.