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
Try navigating with your keyboard! Press Tab to move forward,Shift+Tab to move backward. Press Enter or Space to activate buttons.
❌ What's wrong:
• Inputs have no labels
• Div used as button
• Custom controls not accessible
• Can't navigate with keyboard
Tab through the form to see focus tracking...
1// ✅ Accessible Form with Keyboard Support2 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 <input11 id="name"12 type="text"13 required14 aria-required="true"15 // Visible focus styles16 className="focus:ring-2 focus:ring-blue-500"17 />18 19 {/* Use real buttons, not divs */}20 <button type="submit">21 Submit22 </button>23 24 {/* Checkboxes need labels too */}25 <input26 id="subscribe"27 type="checkbox"28 />29 <label htmlFor="subscribe">30 Subscribe to newsletter31 </label>32 </form>33 );34}35 36// ❌ Common Mistakes37 38// 1. Div as button (not keyboard accessible)39<div onClick={handleClick}>Click Me</div>40 41// 2. Input without label42<input placeholder="Name" />43 44// 3. No visible focus styles45<button className="focus:outline-none">Bad</button>46 47// 4. Custom controls without ARIA48<div onClick={toggle}>☐ Checkbox</div>49 50// ✅ Better Alternatives51 52// 1. Use real button53<button onClick={handleClick}>Click Me</button>54 55// 2. Always add labels56<label htmlFor="name">Name</label>57<input id="name" />58 59// 3. Visible focus indicators60<button className="focus:ring-2 focus:ring-blue-500">61 Good62</button>63 64// 4. Use native controls or proper ARIA65<input type="checkbox" /> {/* Native */}66<div67 role="checkbox"68 aria-checked={checked}69 tabIndex={0}70 onKeyDown={handleKey}71>72 ☑ Custom Checkbox73</div>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
ADA, Section 508, and WCAG compliance are legally required in many countries. Inaccessible sites can face lawsuits.
15% of the world (~1 billion people) have disabilities. That's a huge market you don't want to exclude!
Accessible design benefits everyone: mobile users, elderly, anyone with temporary impairment, and power users.