Build buttons that work for every user — mouse, keyboard, screen reader and voice control. Covers 4 real-world variants in Vanilla HTML/CSS/JS and React, with keyboard, screen reader and testing guidance.
WCAG: 2.1.1 · 2.4.7 · 2.5.5 · 4.1.2
Level: Beginner
Icons: lucide-react
1
What we are building
A reusable button pattern that works for every user, in every stack.
What we are building
A button looks simple, but it is the component with the highest number of accessibility defects on the web. We will build one correctly in two stacks (Vanilla and React), and show you how to repair the three common markup variants you will inherit from legacy codebases.
2
The 4 real-world variants
You will see all of these in production code. Each tab shows the inaccessible version and the fix.
The 4 real-world variants
Variant A
Native <button>
Preferred
Live example
Clicked 0 times
HTML · Accessible
<!-- Native button: keyboard, screen-reader, focus all work for free -->
<button type="button" onclick="handleSave()">
Save Changes
</button>
If you control the markup, this is always the right choice. Browser provides focus, keyboard activation, and screen reader semantics for free.