Notes on Udacity's Web Accessibility course.
- Don't use low constrast text.
- Don't use tiny text
- Make click areas big
- Include keyboard controls. Make them good.
- Don't rely on colours to communicate important information
- Lay things out sensibly so that related components line up
All these things help people with various kinds of impairments, but also help normal users a bit.
Some impairments people might have:
- Partial sightedness
- Inability to use a mouse
- Inability to use a keyboard
- Inability to speak
Some tools people use to assist them:
- Text to speech, including screen readers
- Brail displays
- Alternative colour display software
- Eye tracker
- Voice control
Common Classifications of Impairments
And also by how long they last:
- in impairment resulting from choice or cirumstances
Web Content Accessibility Guidelines (WCAG) is a standard.
- can visually and hearing impaired people see it
- can motor impaired people navigate it
- are the content and possible actions clear
- does it work on a variety of browsers
Complicated, but they also provide a checklist.
People who use assistive technology need to be able to select interactive controls on the page.
Tab order is the order in which elements on the page become focused as you hit tab. By default, this is in DOM element order (not layout order). You can use tabindex to change this.
Elements with positive numbers for tabindex go ahead of the natural ordering in ascending order. It's usually better to reorder the DOM instead.
However, if you have some kind of single-page application, you may need to manipulate the tabindex attributes yourself.
You can look at the focused elements using
Look at the ARIA best practices document to work out which keys you should map for which types of control.
There is a technique called roving focus, where you set all the options inside a control except for one to have tabindex of -1. This means that, when you tab back to that control, you are also focused on the appropriate option. It also means that tab doesn't go through all the options — use the cursor keys for that.
Focus on Invisible Elements
If things are off the screen, you may not want them to come into focus.
Tabbing through lots of content is annoying. We can add a link to our main content ahead of our menu items. This link should only be visible on the screen on focus.
We also need to make our the content element focusable for this to work.
When you have a modal dialogue, remember that you need to trap the tab key behaviour.
There is a dialog element to address this, but it doesn't exist in most browsers yet.
Assistive technologies often aren't visual, so they can't take advantage of the visual layout of the page. Instead, they use the semantic tree. The semantic tree is derived from the DOM, but throws away elements which are purely visual.
The way to make this work: use the correct HTML elements for controls. Label controls properly. Put the alt attribute on images.
Similarly, getting the header hierarchy correct is quite important.
Affordances are usability conventions. We can see them in objects in the world around us (for example, handles on different objects usually have a similar design), but also in software UI.
Standard controls like scrollbars, radio buttons, check boxes, text input fields and so on are affordances. If we use the standard HTML elements, these will be advertised to screen readers and so on.
Writing Good Alt Text
Images should have alt text. Redundant images should have blank alt text.
What's a redundant image?
- UI decoration — like a magnifying glass icon in a search box
- An image inside a link, where the link also contains the same text already
Keep alt text short. Don't use "image of", "graphic of" or "logo". The assistive technology will probably tell them that anyway.
Similarly, you don't need to write "link to" on images which are inside links.
A simpler option for UI decoration is to add it using CSS. This way, it will not be picked up by assistive technology.
For assistive technology to work, links must be done right, having a sensible description and href. Again, images inside links should have alt text.
A link being used to fake a button is also a bit of a mess.
You should be able to recognise what the link is for when looking at the link text out of context. Conversely, it should be as brief as possible.
The Accessible Rich Internet Applications (ARIA) specification is for when you need to use an HTML element incorrectly. It also helps when you need to invent some new semantics that aren't included in HTML.
It does this by adding some attributes (role, state and properties) to HTML elements. These new attributes alter the accessibility tree.
<div role="checkbox" aria-checked="true">A checkbox which is checked</div>
ARIA 1.1 roles. These roles have an inheritance hierarchy where attributes come from. It's best to check in the ARIA practices for simple instructions on how to implement a particular kind of control correctly.
Properties about relationships:
- a list of ids for label text elements
- a list of ids for help information elements
- a list of ids which should be underneath this element in the accessibility tree
Properties about notifications:
- when should notifications be read out to the user (off/polite/assertive)?
- in conjunction with aria-live, should we notify about everything in here even if only one part of it changes (true/false)?
- which types of changes trigger notifications (additions/removals/text/all)?
- ignore all the above (true/false)?
We can target ARIA attributes in our CSS to avoid some duplication.
Similarly, we should aim to use landmarks, which are HTML elements representing overall page structure (
nav, and so on) instead of CSS classes.
Colour and Contrast
We should ensure minimum differences in terms or hue (colour) and luminance (contrast), so that people can read our content with bad eyes on bad screens.
The web accessibility guidelines recommend the following:
|Recommendation||Small||Large (18pt+) or bold (14pt+|
We should also avoid using colour alone to convey information. There should be extra indicators as well, such as underlining.
You can check accessibility using the Chrome dev tools audit tab.
You can also look at the accessibility properties for individual elements.
You can use the NoCoffee Chrome extension to simulate colour blindness.