Semantic HTML First: Making React Components Accessible by Default
JSX renders divs and spans by default — accessibility has to be engineered in, starting with the elements you choose before you reach for ARIA.
JSX renders divs and spans by default — accessibility has to be engineered in, starting with the elements you choose before you reach for ARIA.
React's component model is opinionated about state, props, and rendering lifecycle, and almost silent about what the resulting DOM should mean to anyone not looking at a screen. JSX compiles down to React.createElement calls that happily produce a tree of generic <div> and <span> elements, each one semantically empty until you tell the browser otherwise. A screen reader has no idea your purple rounded rectangle is a button unless you've given it a reason to think so.
TL;DR: React gives you componentization, not accessibility. JSX renders whatever tags you write, and a div with an onClick handler means nothing to a screen reader. Accessible React starts with semantic HTML elements, reaches for ARIA only when no native element fits, and treats keyboard navigation, focus management, and live-region announcements as explicit engineering tasks, not afterthoughts.
This isn't just a procurement-checklist concern. Production React apps routinely ship keyboard traps, unlabeled form fields, and toast notifications that only sighted mouse users ever notice, bugs that stay invisible in a visual QA pass. Teams that get this right, with semantic markup and deliberate focus handling baked into components, are the same teams worth trusting with serious production work. If you're trying to hire react web developers for work like this, ask to see how their past components behave for a keyboard-only user; it's one of the more honest signals available before a contract is signed.
Every React component compiles down to a call like React.createElement('div', props, children). React doesn't know or care what a <div> means to the accessibility tree; it only cares about reconciling virtual DOM nodes efficiently. The browser builds its own accessibility tree from whatever HTML elements actually land in the DOM, and that tree is what screen readers, switch devices, and voice control software read.
This is how <div onClick> buttons sneak into so many codebases. Visually, a styled div with a click handler is indistinguishable from a real button. To a screen reader, it's an anonymous, non-focusable node, invisible to someone navigating by Tab key and silent to someone navigating by voice command. React's abstraction layer sits on top of the DOM; it inherits HTML's accessibility model but doesn't add anything to it automatically.
The first rule of ARIA, straight from the W3C's own guidance, is: don't use ARIA if a native HTML element or attribute already does the job. That rule applies with extra force inside React components, where it's tempting to reach for role="button" on a div because the div is already styled and adding a real <button> means touching the CSS.
Compare the two versions of the same component:
// Anti-pattern: looks like a button, isn't one
function SaveButton(props) {
return (
<div className="btn" onClick={props.onSave}>
Save changes
</div>
);
}
// Fixed: native button, same visual result
function SaveButton(props) {
return (
<button type="button" className="btn" onClick={props.onSave}>
Save changes
</button>
);
}The fixed version is free. A <button> is focusable by default, triggers on both Enter and Space, exposes a button role to assistive technology without any extra markup, and participates correctly in forms. The div version requires you to hand-roll tabIndex={0}, role="button", an onKeyDown handler for Enter and Space, and aria-disabled logic you'd otherwise get from the native disabled attribute, and it's still easy to miss one of those and ship a component that's broken for exactly the users who can't use a mouse. The same logic extends through the rest of the component tree: reach for <nav>, <main>, <dialog>, and real form elements inside your components before you reach for a generic container and a role attribute. See MDN's guide to ARIA for the full "don't use ARIA" rationale.
ARIA earns its place where HTML runs out of native equivalents. Tabs, comboboxes, custom dropdowns, and tree views have no single HTML element that captures their behavior, so you're building a custom widget and the burden of describing it to assistive technology falls on you.
In those cases, a few attributes carry most of the weight: aria-label or aria-labelledby names a control with no visible text label, aria-expanded tells assistive technology whether a disclosure or menu is open, and aria-modal="true" tells screen readers to treat everything outside an open dialog as temporarily inert. Each of these attributes is a promise about behavior: setting aria-expanded="true" when the dropdown isn't actually open and reachable makes the experience worse than having no ARIA at all. A mismatched ARIA state is more damaging than missing semantics, because it actively tells assistive technology something false.
Mouse-driven testing hides an entire category of bugs that only show up when you unplug the mouse. In a component tree, focus has to be managed explicitly in three recurring situations: trapping focus inside an open modal so Tab can't escape to the page behind it, restoring focus to the element that opened the modal once it closes, and implementing roving tabindex for composite widgets like menus and lists, where only one item sits in the Tab sequence at a time while arrow keys move a tabIndex={0}/tabIndex={-1} pointer between siblings.
None of this is handled by React itself; it's DOM API work (element.focus(), useRef, useEffect cleanup) living inside component lifecycle hooks. A modal that doesn't call .focus() on mount and restore focus on unmount is accessible on paper and broken in practice for anyone navigating by keyboard.
Forms are where accessibility gaps turn into completed-task failures, not just inconvenience. The baseline is unglamorous: every input needs a <label htmlFor> pointing at its id, not a placeholder standing in for a label, and not a visually adjacent <span> with no programmatic connection.
Error handling is where React forms usually go wrong in a new way: validation that fires on every keystroke and updates an aria-live region on each change produces a screen reader that announces a half-typed email address as invalid on every character. Validate on blur or on submit, announce once a meaningful state is reached, and associate the error message to its field with aria-describedby so the connection survives focus changes. The site's own WCAG 2.2 checklist for accessible forms covers the full criteria list if you're auditing an existing form rather than building a new one.
React applications update the DOM constantly without a page reload (toasts, filtered search results, async-loaded lists), and none of those updates are announced to a screen reader unless you mark that region as live. aria-live="polite" queues an announcement for when the user is idle, right for things like "3 results found" or a save confirmation. aria-live="assertive" interrupts immediately, reserved for genuinely urgent state like a session timeout or a failed payment.
The common mistake is wiring up a live region and then re-rendering its container with a brand-new DOM node on every update. Some screen reader and browser combinations only announcechanges to an element that persists in the tree, not one that's unmounted and remounted. Keep the container mounted for the life of the page and change only its text content.
Libraries like Radix UI, Reach UI, React Aria, and Chakra UI exist because hand-rolling correct keyboard behavior for a combobox or dialog, every time, in every project, is hard to get right and easy to regress. They encode the same POUR principles (Perceivable, Operable, Understandable, Robust) covered above into unstyled or lightly styled primitives,so a Dialog component from Radix already traps focus, restores it on close, and sets aria-modal correctly.
A library doesn't replace the need to understand why those behaviors matter. You'll still misuse an accessible primitive if you don't understand focus management, and you'll still need judgment on which custom components genuinely need a library versus which are simple enough that a well-built native-element component handles the job without a dependency.
axe-core and its React testing wrapper, jest-axe, are worth running in CI: they'll reliably catch missing form labels, insufficient color contrast, and a handful of other rule-based violations. What they can't catch is a keyboard trap, a confusing tab order, or a focus target that lands somewhere unexpected. These are behavioral problems, and automated tools check static accessibility-tree properties, not the experience of navigating the page.
The only reliable test for keyboard and screen reader behavior is doing it yourself: unplug the mouse, navigate your component with Tab, Shift+Tab, Enter, Space, and arrow keys, and confirm you can reach, operate, and escape every interactive element in the order you'd expect. The W3C's WAI-ARIA Authoring Practices Guide documents the expected keyboard behavior for every common widget pattern, the closest thing to an answer key for a manual pass.
Not beyond what you get from writing plain HTML inside your JSX. React renders whatever elements you specify; if you write semantic elements, you get their built-in accessibility behavior for free, and if you write generic divs and spans, you get none of it. React itself adds no accessibility layer on top of the DOM.
No. ARIA is only needed for components that have no native HTML equivalent (custom tabs, comboboxes, trees, and similar widgets). A component built from native elements like <button>, <nav>, or <dialog> typically needs no ARIA attributes at all.
polite waits for a natural pause before announcing an update, suitable for routine changes like search result counts. assertive interrupts whatever the screen reader is currently announcing, and should be reserved for urgent, time-sensitive messages like a failed submission or an expiring session.
No. They handle the implementation details correctly by default, but you still need to understand focus management and ARIA semantics to use them correctly, combine them with custom components, and debug issues when they arise.
No. Tools like axe-core catch rule-based violations (missing labels, poor contrast, invalid ARIA attributes), but they can't detect behavioral problems like keyboard traps or a confusing focus order. Manual keyboard and screen reader testing is still required.
Capture a reference to the element that had focus before the modal opened, move focus into the modal on mount, and call .focus() on that saved reference when the modal unmounts. Skipping this step leaves keyboard users with focus lost on the body element after closing a dialog.
No. A <button>, <nav>, or <ul> can be styled identically to a <div> with CSS; semantic elements don't come with mandatory default appearances you can't override. The accessibility benefits are free; the perceived styling cost is a myth.