
Accessibility is one of the easiest ways to stand out in a frontend interview, simply because so many candidates skip it. In UI rounds, a lot of people build a working component with divs and click handlers, and never mention keyboard users or screen readers.
Interviewers at larger companies often notice, because their products have to work for everyone (and often have legal requirements to). Here are the accessibility questions that come up, the checklist I run in every UI round, and code for the components interviewers like to ask about.
The checklist I run on every UI question

Once my component works, I spend about two minutes on these five checks and say them out loud. Even if I don’t have time to implement everything, naming what I’d add earns credit.
1. “Why use a button instead of a div with onClick?”
This is the most common accessibility question, and the answer goes deeper than “semantics”.
A native <button> gives you, for free:
- It’s focusable with Tab.
- It activates with Enter and Space.
- Screen readers announce it as a button.
- It supports
disabledcorrectly.
To make a div behave the same, you’d need role="button", tabindex="0", and key handlers for Enter and Space. That’s more code, and more ways to get it wrong. This is the “first rule of ARIA”: if a native element does the job, use it.
2. “What is ARIA, and when should you use it?”
ARIA (Accessible Rich Internet Applications) is a set of attributes that describe roles, states, and properties to assistive technology. It changes what screen readers announce. It does not add behavior: role="button" doesn’t make something keyboard accessible.
Use it when HTML doesn’t have a native element for what you’re building (tabs, comboboxes, tree views) or to communicate state:
aria-expandedon a toggle that opens a menu or accordion.aria-selectedon the active tab or option.aria-pressedon toggle buttons like Like or Bold.aria-labelfor icon-only buttons.aria-livefor content that updates asynchronously.
Bad ARIA is worse than no ARIA. A wrong role makes a screen reader describe your component incorrectly.
3. “How would you make a modal accessible?”
This comes up constantly, both as a trivia question and as a UI build. A strong answer covers:
- Semantics:
role="dialog"andaria-modal="true", witharia-labelledbypointing at the title. Or use the native<dialog>element withshowModal(), which handles a lot of this for you. - Focus in: move focus into the modal when it opens.
- Focus trap: Tab and Shift+Tab cycle within the modal.
- Escape closes it.
- Focus out: return focus to the button that opened it when it closes.
- Background: content behind it isn’t reachable (native
showModal()makes it inert).
function Modal({ open, onClose, title, children }) {
const dialogRef = useRef(null);
useEffect(() => {
const dialog = dialogRef.current;
if (!dialog) return;
if (open && !dialog.open) dialog.showModal(); // focus moves in, background becomes inert
if (!open && dialog.open) dialog.close(); // focus returns to the opener
}, [open]);
return (
<dialog ref={dialogRef} aria-labelledby="modal-title" onClose={onClose}>
<h2 id="modal-title">{title}</h2>
{children}
<button onClick={onClose}>Close</button>
</dialog>
);
}
The native dialog handles Escape (it fires a close event), the focus trap, and the inert background. Mentioning that you know both the manual approach and the native one shows depth. Practice the full version with Design an Accessible Dialog.
4. “How do you build accessible tabs?”
function Tabs({ tabs }) {
const [active, setActive] = useState(0);
const tabRefs = useRef([]);
function onKeyDown(e) {
const last = tabs.length - 1;
let next = null;
if (e.key === 'ArrowRight') next = active === last ? 0 : active + 1;
if (e.key === 'ArrowLeft') next = active === 0 ? last : active - 1;
if (e.key === 'Home') next = 0;
if (e.key === 'End') next = last;
if (next === null) return;
e.preventDefault();
setActive(next);
tabRefs.current[next]?.focus();
}
return (
<>
<div role="tablist" onKeyDown={onKeyDown}>
{tabs.map((tab, i) => (
<button
key={tab.id}
ref={(el) => { tabRefs.current[i] = el; }}
role="tab"
id={`tab-${tab.id}`}
aria-selected={i === active}
aria-controls={`panel-${tab.id}`}
tabIndex={i === active ? 0 : -1}
onClick={() => setActive(i)}
>
{tab.label}
</button>
))}
</div>
{tabs.map((tab, i) => (
<div
key={tab.id}
role="tabpanel"
id={`panel-${tab.id}`}
aria-labelledby={`tab-${tab.id}`}
hidden={i !== active}
>
{tab.content}
</div>
))}
</>
);
}
The key detail is the roving tabindex: only the active tab is in the Tab order (tabIndex={0}), and arrow keys move between tabs. Pressing Tab moves focus out of the tab list into the panel, which is what screen reader users expect.
5. “How do you announce dynamic content?”
When content changes without a page load (search results update, a form saves, a toast appears), screen reader users don’t know unless you tell them. Use a live region:
<div aria-live="polite" className="visually-hidden">
{results.length} results found
</div>
polite waits until the screen reader is idle. assertive interrupts, so save it for urgent errors. One gotcha: the live region should exist in the DOM before its content changes, or some screen readers won’t announce it.
6. “How do you hide something visually but keep it for screen readers?”
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
Not display: none and not visibility: hidden, because both hide content from screen readers too. I compare them in CSS interview questions that trip up senior engineers.
7. “How would you test accessibility?”
| Method | Catches |
|---|---|
| Automated tools (axe, Lighthouse) | Missing labels, low contrast, invalid ARIA. Only part of the problems |
| Keyboard-only walkthrough | Unreachable controls, focus traps, invisible focus |
| Screen reader (VoiceOver, NVDA) | Confusing announcements, missing state, wrong reading order |
| Zoom to 200% and reduced motion | Broken layouts, motion sickness triggers |
Saying “automated tools only catch part of the issues, so I’d also test with a keyboard and a screen reader” is exactly the kind of practical answer interviewers want.
8. “What is WCAG?”
The Web Content Accessibility Guidelines, the standard most companies and laws point to. Know the four principles (content must be Perceivable, Operable, Understandable, and Robust) and that most companies aim for level AA. A specific number worth remembering: normal text needs a contrast ratio of at least 4.5:1 for AA.
How to practice
Take any UI question you’ve already solved (an autocomplete, tabs, a modal, a carousel), unplug your mouse, and try to use it with only the keyboard. Then turn on VoiceOver or NVDA and try again. You’ll find gaps quickly, and you’ll remember the fixes because you felt the problem.
The free HTML fundamentals guide covers the semantic HTML side, and the system design section has accessible component designs like the dialog, dropdown menu, and carousel.
And that’s it, folks. Accessibility takes two minutes in an interview and makes a strong impression. Make the checklist a habit and you’ll do it without thinking.
