Throughout the session I'm doing to be doing exercises on a dummy page. You can play along if you want. The address is:
In order to understand the accessibility tree, we need to quickly cover Accessibility APIs.
Accessibility APIs communicate information about the user interface from the browser to the Assistive Technology.
Browsers use the DOM, along with some aspects of CSS, to generate an Accessibility Tree.
This Accessibility Tree exposes information on specific elements to Assistive Technologies via the Accessibility API.
Information includes:
Each browser will produce a unique Accessibility Tree due to their specific source code/Accessibility API combination.
The Accessibility Tree is extremely important in understanding how information is presented to assisitive technologies.
For this presentation, I’ll be using Chrome’s accessibility tree as the example.
First, let’s inspect the “What are mammals?” heading. What is this elements role
and level
the Accessibility Tree?
Next, let’s inspect the “Full name” <input>
. What is this elements role
in the Accessibility Tree?
If we inspect the “Email” <input>
, is it defined as being required
in the Accessibility Tree?
If we type some content into the “Email” <input>
field, will it now have a value
in the Accessibility Tree?
What if we choose “Aardvark” from the “Favourite Mammal” dropdown? Does the <select>
element now have a value
in the Accessibility Tree?
Let’s check “Yes” from the “Subscribe to newsletter” checkbox group. Does the checkbox now have a checked
status in the Accessibility Tree?
Let's now look at the <fieldset>
element and find its accessible name.
What about the <main>
element? What is its accessible name?
And finally, the <table>
element. What is its accessible name?
As you can see, there are a wide range of possible properties that can be presented within the Computed properties frame, depending on the element being inspected.
Name: [ accessible name as a text string ]
Role: [ pre-defined list of roles ]
Description: [ description as a text string ]
Value: [ current value as a text string ]
Required: true | false
Expanded: true | false
Checked: true | false
Disabled: true | false
Described by: [ element][#id][.class ]
Labeled by: [ element][#id][.class ]
Accessible names are names given to elements in the Accessibility tree.
Accessible names are very important for Assistive Technology users as they help to identify elements within the accessibility tree.
Accessible names are defined as text strings.
Chrome’s accessibility tree shows all the possible options that could be used to provide the accessible name.
It also displays the final computed accessible name as a text string.
Accessible names can be applied to elements in a range of different ways, depending on the element.
The contents of links and buttons can be converted into text strings and used as their accessible names.
<a href="#">Content</a>
<button>Content</button>
The value of the alt
attribute for an image can be converted into a text string and used as the accessible name.
<img src="ball.jpg" alt="Content">
For elements that allow the title
attribute, the title
value can be converted into a text string and used as the accessible name.
<button title="Content"></button>
For some elements, the placeholder
value can be converted into a text string and used as the accessible name.
<input type="text" placeholder="Content">
For some elements, the aria-label
value can be converted into a text string and used as the accessible name.
<button aria-label="Content"></button>
The contents of the <label>
element can be converted into a text string and used as the accessible name for <input>
, <select>
and <textarea>
elements.
<label for="name">Content</label>
<input id="name" type="text">
The contents of the <caption>
element can be converted into a text string and used as the accessible name for the <table>
element.
<table>
<caption>Content</caption>
</table>
The value of aria-labelledby
attribute can be converted into a text string and used as the accessible name for various elements.
<div aria-labelledby="heading">
<h2 id="heading">Content</h2>
</div>
Let’s inspect the “Email” <input>
. What is this elements name in the Accessibility Tree?
Let’s look at the first “Find out more” link on the page. In theory, the accessible name for this element should be “Find out more”.
In the case of <a>
and <button>
elements, and elements with role="button"
or role="link"
, the rules are:
aria-labelledby
.aria-label
.title
.In the case of <img>
elements, the rules are:
aria-labelledby
.aria-label
.alt
.title
.In the case of most of the common <input>
elements, <select>
and <textarea>
elements, the rules are:
aria-labelledby
.aria-label
.<label>
element(s).title
.placeholder
.An accessible description provides additional information, related to an interface element, that complements the accessible name.
The accessible description might or might not be presented visually on-screen.
Like accessible names, accessible descriptions are defined as text strings.
Inspect the “Address” input. What is this elements description
in the Accessibility Tree?
How are the accessible name and description announced in different screen readers?
Screen readers announce objects within the accessibility tree in the following order:
Let’s use the “Address” <input>
again to see the announcement order in different screen readers.
With Voiceover, there is a pause after the accessible name and role are announced.
How ARIA works can be defined in three simple statements:
ARIA can be used change and augment the Accessibility Tree in the following ways:
i.e. modifying the existing semantics of elements via the role attribute.
<button role="tab"></button>
i.e. informing Assistive Technologies of a widget’s current state.
<button aria-expanded="true"></button>
i.e. adding additional labelling to elements.
<button aria-label="Close modal"></button>
i.e. adding descriptions to elements.
<input type="text" aria-describedby="a1">
<span id="a1">Error message</span>
i.e. informing Assistive Technologies of the relationships between specific elements, than may not be possible via the DOM.
<button role="tab" aria-controls="a1"></button>
<div role="tabpanel" id="a1"></div>
i.e. Defining region “live” and may change.
<div aria-live="polite"></div>
We will now look at some common problems that can be identified directly via the Accessibility Tree.
Hopefully, this presentation has provided you with: