Accessibility
The Art of Accessible UI Design
• 8 min read
The Art of Accessible UI Design
Web accessibility (a11y) is the practice of ensuring there are no barriers that prevent interaction with, or access to, websites on the World Wide Web by people with physical disabilities, situational disabilities, and socio-economic restrictions on bandwidth and speed.
Key Principles
- Semantic HTML: Use the correct HTML element for the job. Buttons for actions, links for navigation.
- Keyboard Navigation: Ensure all interactive elements can be reached and activated using a keyboard.
- Visual Hierarchy: Use proper heading levels (h1-h6) to structure your content.
- Color Contrast: Ensure sufficient contrast between text and background colors.
Example: Accessible Button
<!-- Bad -->
<div onclick="submit()">Submit</div>
<!-- Good -->
<button type="button" onClick="submit()">Submit</button>
Using a generic div requires you to reimplement keyboard event handling and focus styles. A button gives you all of that for free.