^.^;
All Demos

Accessibility Deep Dive

Learn web accessibility best practices. Make your sites usable for everyone through keyboard navigation, screen readers, ARIA, and color contrast.

Learn proper keyboard accessibility and focus management

Interactive Testing Lab

Try navigating with your keyboard! Press Tab to move forward,Shift+Tab to move backward. Press Enter or Space to activate buttons.

🎹 Last Key Presses

Press any key...

✅ Accessible Form

✅ What makes this accessible:
• All inputs have proper labels
• Focus states are visible
• Required fields marked
• Keyboard navigable

❌ Inaccessible Form

Click Me (Not a Real Button)
Subscribe

❌ What's wrong:
• Inputs have no labels
• Div used as button
• Custom controls not accessible
• Can't navigate with keyboard

Focus History (Last 5 elements)

Tab through the form to see focus tracking...

⌨️ Essential Keyboard Shortcuts

TabMove to next focusable element
Shift + TabMove to previous element
EnterActivate buttons/links
SpaceToggle checkboxes/buttons
Arrow KeysNavigate within groups
EscClose modals/menus

Code Examples

Accessibility Patterns
1// ✅ Accessible Form with Keyboard Support
2
3function AccessibleForm() {
4 return (
5 <form onSubmit={handleSubmit}>
6 {/* Always use label with htmlFor */}
7 <label htmlFor="name">
8 Name <span aria-label="required">*</span>
9 </label>
10 <input
11 id="name"
12 type="text"
13 required
14 aria-required="true"
15 // Visible focus styles
16 className="focus:ring-2 focus:ring-blue-500"
17 />
18
19 {/* Use real buttons, not divs */}
20 <button type="submit">
21 Submit
22 </button>
23
24 {/* Checkboxes need labels too */}
25 <input
26 id="subscribe"
27 type="checkbox"
28 />
29 <label htmlFor="subscribe">
30 Subscribe to newsletter
31 </label>
32 </form>
33 );
34}
35
36// ❌ Common Mistakes
37
38// 1. Div as button (not keyboard accessible)
39<div onClick={handleClick}>Click Me</div>
40
41// 2. Input without label
42<input placeholder="Name" />
43
44// 3. No visible focus styles
45<button className="focus:outline-none">Bad</button>
46
47// 4. Custom controls without ARIA
48<div onClick={toggle}>☐ Checkbox</div>
49
50// ✅ Better Alternatives
51
52// 1. Use real button
53<button onClick={handleClick}>Click Me</button>
54
55// 2. Always add labels
56<label htmlFor="name">Name</label>
57<input id="name" />
58
59// 3. Visible focus indicators
60<button className="focus:ring-2 focus:ring-blue-500">
61 Good
62</button>
63
64// 4. Use native controls or proper ARIA
65<input type="checkbox" /> {/* Native */}
66<div
67 role="checkbox"
68 aria-checked={checked}
69 tabIndex={0}
70 onKeyDown={handleKey}
71>
72 ☑ Custom Checkbox
73</div>

♿ Understanding A11y

Keyboard accessibility ensures users can navigate and interact with your site without a mouse. **Key principles:** - **Tab order**: Elements should be reachable via Tab key in logical order - **Focus indicators**: Users must see what's focused (never use outline: none without replacement) - **Semantic HTML**: Use buttons, inputs, and links - not divs with onClick - **Labels**: Every form control needs an associated label **Common issues:** - Divs used as buttons (not keyboard accessible) - Missing labels on inputs - Invisible or removed focus indicators - Custom controls without proper keyboard support

💡 Key Learnings

  • All interactive elements must be keyboard accessible
  • Tab and Shift+Tab navigate through focusable elements
  • Always use semantic HTML (button, input, a) not divs
  • Every input needs a proper label element
  • Focus indicators must be visible (avoid outline: none)
  • Enter activates buttons, Space toggles checkboxes
  • Custom controls need tabIndex and keyboard event handlers
  • Skip links help users jump to main content

♿ Why Accessibility Matters

It's the Law

ADA, Section 508, and WCAG compliance are legally required in many countries. Inaccessible sites can face lawsuits.

Massive Audience

15% of the world (~1 billion people) have disabilities. That's a huge market you don't want to exclude!

Better UX for All

Accessible design benefits everyone: mobile users, elderly, anyone with temporary impairment, and power users.

Terms of ServiceLicense AgreementPrivacy Policy
Copyright © 2025 JMFG. All rights reserved.