Accessibility Basics for Frontend Interviews
Semantic HTML, keyboard navigation, focus management, labels, ARIA basics, and the accessibility mistakes interviewers look for.
On this page
30‑second interview answer
Web accessibility means building interfaces usable by everyone, including keyboard-only and screen-reader users. The basics: semantic HTML, keyboard navigation, visible focus states, correct labels, and minimal ARIA (only where necessary). If it works with keyboard and screen reader, it’s usually accessible.
The 5 essentials interviewers expect
- Keyboard
- Everything interactive must be reachable via Tab
- Enter/Space activates controls
- Focus states
- Focus must be visible (don’t remove outlines without a replacement)
- Semantics
- Use
button,a,label, headings, landmarks
- Labels & names
- Inputs need labels
- Buttons need accessible names
- Contrast
- Text should have sufficient contrast
Semantic HTML first
Native elements give you the role, focus and keyboard behaviour for free. That is why "use semantic HTML" is the first answer interviewers want.
button vs div for clickable UI
Bad:
<div onclick="doThing()">Save</div>It isn't focusable, has no role, and ignores Enter and Space. Fixing it needs role, tabindex and key handlers. Use the real element instead:
<button type="button">Save</button>Landmarks and headings
<header>...</header>
<nav>...</nav>
<main>
<article>...</article>
</main>
<footer>...</footer>Screen-reader users jump between landmarks and headings, so:
- use one
h1for the page topic - don't skip heading levels to get a smaller font; use CSS for size
Forms: labels, not placeholders
Bad:
<input placeholder="Email" />Good:
<label for="email">Email</label>
<input id="email" name="email" type="email" />A visually hidden label is fine if the design has no visible one. Use the right input types (email, tel, url) for better mobile keyboards, and button type="submit" inside forms.
Focus management: modals and menus
When a modal opens:
- move focus into it
- keep focus trapped inside while it's open
- return focus to the element that opened it when it closes
If focus is lost, keyboard and screen-reader users lose their place on the page.
Common a11y mistakes
- Click handlers on
<div>s - Missing
<label for> - Placeholder used as label
- No focus ring
- Missing or meaningless
alton images that carry meaning - Headings chosen for size, skipping levels
- Bad ARIA (“aria-label” everywhere without semantics)
ARIA quick primer (safe interview stance)
- Use ARIA when you build custom components.
- Keep ARIA states accurate:
aria-expandedaria-controlsaria-selected
- Give icon-only buttons a name with
aria-label.
Don’t use ARIA to pretend a div is a button unless you implement full keyboard behavior. The interview line: “No ARIA is better than bad ARIA. Native elements first.”
Practical checklist: dropdown menu
If you build a dropdown:
- focus goes to trigger button
- opening moves focus into menu (or keeps on trigger, but keyboard works)
- Escape closes
- Up/Down navigates items
How to test it quickly
- Unplug the mouse: can you reach and use everything with Tab, Enter, Space and Escape?
- Run the Lighthouse accessibility audit.
- Try a screen reader for a few minutes (VoiceOver on macOS, NVDA on Windows).
Mini Q&A
Q1: Fastest a11y improvement?
- Semantic HTML + focus styles.
Q2: Why is placeholder not a label?
- It disappears, not read consistently, harms usability.
Q3: What’s your ARIA philosophy?
- Native first; ARIA for gaps.
Q4: Why <button> instead of a clickable <div>?
- The button is focusable, announced as a button, and works with Enter and Space without extra code.
Q5: What should happen to focus when a modal closes?
- It returns to the element that opened the modal.
Summary checklist
- Interactive elements are real
buttons and links. - Everything works with keyboard.
- Modals move, trap and restore focus.
- Focus is visible.
- Labels exist.
- Contrast is OK.
- ARIA used only when needed.
Looking for structured, offline interview prep?
Free online lessons • Portable Amazon Kindle / Paperback
Frontend Interview Guide (2025 Edition)
By Rajesh Dhiman
Comprehensive preparation covering React internals, Web Performance, CSS architecture, and system design questions.
Frontend Interview Guide (2025 Edition)
By Rajesh Dhiman
Comprehensive preparation covering React internals, Web Performance, CSS architecture, and system design questions.
Note: All lessons on Frontend Interview remain completely free to read online. As an Amazon Associate I earn from qualifying purchases.
Written by Rajesh Dhiman
Authored by Rajesh Dhiman and engineered at Eunix Tech. Focused on deep-dive frontend engineering, JavaScript runtime internals, React architecture, and web performance.