This presentation was fro the AllyBtyes event on 21 May 2020. The presentations looks at a pattern for building or reviewing any new UI component – semantics, focusable, keyboard interaction, visible states, accessible name and relationships.
9. Using HTML elements incorrectly can
cause confusion for Assistive
Technologies.
10. If an element is being used in a
different way to its intended purpose,
it should be assigned an explicit
ARIA role.
11. // This div element is being used as a button, so it
will need a role of "button", so that its purpose is
understood by assistive technologies:
<div role="button"></div>
16. // By default, the accessible name for links is
defined via the link content:
<a href="a.html">Red fish</a>
17. // The accessible name for images is defined via the
value of the alt attribute (if present):
<img src="a.png" alt="Red fish">
18. // The accessible name for form controls can be
defined via the label content, if these two elements
are explicitly associated:
<label for="fish">Red fish</label>
<input id="fish" type="text">
19. For some UI components, there is no
accessible name, or the existing
name lacks clarity.
20. In these cases, specific ARIA
attributes can be used to provide a
new accessible name.
21. // If the button content lacks meaning, the
accessible name can be defined via the aria-label
value:
<button aria-label="Close and go to Red fish">
X
</button>
38. These states must be clearly
communicated to assistive
technologies.
39. For native HTML elements like radio
and checkboxes, these states are
baked-in.
40. However, when using non-native
elements, ARIA has to be used to
define these states.
41. // In this case, a DIV element has been given an
aria-checked attribute to inform assistive
technology users of its state:
<div
checked
aria-checked="true"
>
</div>
60. 1. Semantics:
2. Accessible name:
3. Focusable:
4. Keyboard interaction:
5. Visible states:
6. Functional states:
7. Existing conventions:
Baked in
Baked in
Baked in
Baked in
Baked in
Baked in
Well known/understood
69. Choose your preferred colours
Red Green Blue
Purple YellowLabels placed on top of the checkboxes
70. Choose your preferred colours
Red Green Blue
Purple Yellow
LabelCheckboxes and labels are
explicitly associated via
matching “for” and “id” values
71. 1. Semantics:
2. Accessible name:
3. Focusable:
4. Keyboard interaction:
5. Visible states:
6. Functional states:
7. Existing conventions:
Baked in
Baked in
Baked in
Baked in
Baked in
Baked in
May not be understood
87. 1. Semantics:
2. Accessible name:
3. Focusable:
4. Keyboard interaction:
5. Visible states:
6. Functional states:
7. Existing conventions:
Will need to be defined
Baked in
Baked in
Will need to be redefined
Will need to be redefined
Will need to be defined
May be misunderstood
88. This method starts out using an
entirely inappropriate element - the
<button> element.
90. // The button would need to be given a role of
checkbox, to inform Assistive Technologies as to its
purpose.
<button
role="checkbox"
>
Green
</button>
91. // When checked, the button would need to be given
an aria-checked attribute, to inform Assistive
Technologies as to its current state.
<button
role="checkbox"
checked
aria-checked="true"
>
Green
</button>
92. This method also has similar problems
to the previous method. It does not
use existing UI conventions.
93. So, this method would also need to
be tested with the intended
audience before being used.