Photo by Daniel Ali on Unsplash
Accessibility Quick Start Guide
Resources to Provide a Gentle Introduction to Accessibility
π Introduction
Oftentimes, accessibility is an afterthought. I was very fortunate to have had a manager that enforced best practices and helped me build my lens for accessibility. My goal is to pay it forward and pass on the lessons I learned so that we can flip the script and make accessibility a forethought when developing user interfaces.
My first step towards this initiative is to create a blog post as a gentle introduction on the topic of accessibility. This is by no means an exhaustive list of resources, but my hope is that it helps point you in the right direction so that you can dive deeper into the topic. I made a similar document for my employer's engineering team and figured this would be a great resource to share with the larger developer community.
π WAI-ARIA Authoring Practices - If you do nothing else, reference this document which is the standard for implementing accessible web components.
βΉοΈ Writing accessible code (easy wins)?
Tips from the Syntax podcast accessibility episode
- Clean HTML
- Semantic elements
- Use the alt attribute on images
- Proper input types - number, text, etc
- Use links and buttons properly
- Colors and proper contrast
- CSS order property on Flexbox and Grid
- HTML5 (article, section, header, footer)
- Use ARIA roles to define elements when semantic HTML falls flat (popups, non-standard controls, etc.)
π Resources
Useful articles, courses, etc, found around the interwebs.
β Web Accessibility by Google
- This is a free course that is provided by Udacity. It covers a lot of solid accessibility fundamentals.
Google Developers - Accessibility Fundamentals
- This is a text-based version of part of the content covered in the course mentioned above.
WebAIM - Keyboard Accessibility - TabIndex
- For situations where you want to modify the tab order, you can leverage the tabindex attribute.
Smashing Magazine - A Complete Guide To Accessible Front-End Components
π οΈ Developer Tools
A list of tools that can be helpful in testing and inspecting accessibility pieces within an application.
- Axe Tools (Free browser extension and other tools)
- Accessibility Insights (Alternative free browser extension)
- VoiceOver (Default screen reader on Mac)
- Learning VoiceOver Basics
- Shortcut β CMD + F5
- Inspect accessibility properties in browsers:
- Lighthouse
- Pa11y (accessibility automation tools)
- Level Access - Free Web Accessibility Testing
- eslint-plugin-jsx-a11y
πΊ Video Tutorials
- A11ycasts Playlist by Google Chrome Developers
- Short and simple video outlining tabindex
- Accessibility Fundamentals with Rob Dodson
π€ Terminology
ARIA β Accessible Rich Internet Applications
WAI-ARIA β Web Accessibility Initiative β Accessible Rich Internet Applications
The term βa11yβ is a shorthand for βaccessibilityβ
ARIA consists of three main components:
Accessibility Tree = the modified DOM tree that the browser presents to the screen reader minus the extra visual style fluff. You can think of it as an API describing the page's structure.
- It's similar to the DOM tree but typically has less information and fewer nodes since it doesn't need all the visual presentation stuff.
- ARIA works by allowing you to specify attributes on elements that modify the way that element is translated into the accessibility tree.
π Semantics and Assistive Technology
- Because not all people are able to visually access a webpage and therefore not able to pick up on all the affordances in the same way, we have to ensure that information is expressed in such a way that it can be accessed programmatically by assistive technology. This is referred to as the semantics of an element.
- In return, the assistive technology is able to create an alternative interface that can suit its user's needs.
- All images should have an
alt
attribute. Images that are important for the page should have descriptivealt
text while purely decorative or cosmetic images should havealt=""
.
π Semantics in Native HTML
The DOM comes pre-packaged with implicit semantic meaning.
Implicit semantic meaning β Using native HTML elements that are automatically and reliably recognized by a wide range of browsers. A major gain of using native HTML elements is that accessibility for these elements is handled by default.
βΉοΈ This is why it's always recommended to use native elements whenever possible. Trying to "build your own" is always more work because you have to ensure that the accessibility meets the WAI-ARIA standards.
- For scenarios where you need something more custom, leverage accessibility-focused libraries that are solid and battle-tested.
π·οΈ Labels and Inputs
- Each input should have a corresponding label. The
for
attribute on the label should correspond with theid
of the input it is labeling.- Inputs should always have labels as well, especially for accessibility reasons.
- Labels are important because they create a connection between an element and its description.
- A label only works with
<input>
elements. If you want to associate a label for standalone form elements like<select>
and<textarea>
you will need to use thearia-labelledby
attribute.- Or put another way - If you can't use a label but want to make it clear that something is the label of something else - use
aria-labelledby
.
- Or put another way - If you can't use a label but want to make it clear that something is the label of something else - use
- Typically, you only want to add focus to interactive elements like buttons, tabs, selects, or anything that users might have to provide input into.
- If you want to hide a label, for use cases like icon buttons, for example, check out my blog post on an Accessible Friendly Way of Hiding a Label.
ππ½ El Fin
I hope this article provided a gentle introduction to the topic of accessibility. I plan to write more targeted topics within accessibility in the future so stay tuned for more!
If you enjoy what you read, feel free to like this article or subscribe to my newsletter, where I write about programming and productivity tips.
As always, thank you for reading, and happy coding!