SPACEBAR to move forward through slides.
SHIFT & SPACEBAR to move backwards through slides.
LEFT ARROW & RIGHT ARROW to move through sections.
ESC to see overview and ESC again to exit.
F to enter presentation mode and ESC to exit.
Before diving into Chrome's accessibility tree, let’s look at three concepts associated with HTML elements:
Accessible names are short text strings that provide assistive technology users with a label for the element.
Accessible names convey the purpose of the element.
They also distinguish the element from other elements on the page.
So, each accessible name should be unique.
Almost all HTML elements have a ‘role’.
These roles are used to define their purpose - especially for assistive technologies.
The <input type="radio">
has the role of radio
.
The <a>
element has a role of link
.
Sometimes, HTML elements need additional context - as well as their short accessible name.
For example, instructions or error messages associated with form controls.
If applied correctly, this additional information is referred to as an accessible description.
Let’s look at a simple form control and its associated label:
<!-- Accessible name -->
<label for="aaa">Address</label>
<span id="bbb">Include full street address</span>
<input id="aaa" type="text"
aria-describedby="bbb" required>
<!-- Role -->
<label for="aaa">Address</label>
<span id="bbb">Include full street address</span>
<input id="aaa" type="text"
aria-describedby="bbb" required>
<!-- Accessible description -->
<label for="aaa">Address</label>
<span id="bbb">Include full street address</span>
<input id="aaa" type="text"
aria-describedby="bbb" required>
<!-- State -->
<label for="aaa">Address</label>
<span id="bbb">Include full street address</span>
<input id="aaa" type="text"
aria-describedby="bbb" required>
Screen readers announce element properties in the following order:
(The following examples have been simplified to explain the overall concepts)
But how do these screen readers access all of this information? Via the accessibility tree.
The accessibility tree is a simplified version of the Document Object Model.
The accessibility tree consists of information about specific HTML elements.
This information is passed on to assistive technologies so that they can understand, navigate and interact with web documents.
Each browser creates its own version of the accessibility tree. They also use their own Accessibility APIs.
This means assistive technologies may have slightly different experiences in each browser.
The Chrome browser has an excellent function called the ‘Computed properties’ panel.
This panel presents a range of accessibility information in one location.
Go to the All about mammals page.
We will spend most of our time exploring the ‘Computed Properties’ panel.
In the Computed Properties panel, find the element’s name
and role
.
All important elements must have names and roles so assistive technologies can understand them.
(We will look at accessible names in detail soon.)
In the Computed Properties panel, find the element’s name
and role
:
<input>
In the Computed Properties panel, find the element’s name
and role
:
In the Computed Properties panel, find the element’s role
and level
:
In the Computed Properties panel, find the <table>
element’s name
and role
:
Inside the table, all essential elements also have roles:
<tr>
role = row<th>
role = columnheader<td>
role = gridcellDoes this element provide any information in the Computed Properties panel:
Some less important elements are not exposed in the accessibility tree.
<input>
In the Computed Properties panel, find the element’s description
:
Descriptions are used to provide additional information for some elements.
(We will look at accessible descriptions in detail soon.)
<input>
Is this element defined as required
in the Computed Properties panel?
This tells assistive technologies that the form control is required and must be filled in before submitting the form.
<input>
Does the element now have a value
in the Computed Properties panel?
This tells assistive technologies what the user has added to the form field - allowing the user to review the information before submitting the form.
Select ‘Aardvark’ from the ‘Favourite mammal’ dropdown. Does the <select>
element now have a value
in the Computed Properties panel?
Check ‘Yes’ from the ‘Bats’ checkbox group. Does the checkbox now have a checked
status in the Computed Properties panel?
This tells assistive technologies that the form control has been checked.
This will create some fake form errors. Inspect the ‘Phone’ <input>
. Is this element defined as invalid
in the Computed Properties panel?
This tells assistive technologies that the form control is currently invalid and needs to be resolved.
There is a wide range of possible properties that can be presented in Chrome’s accessibility tree, depending on the element:
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]
Labeled by: [element #id]
ARIA is a set of custom HTML attributes that add information to the accessibility tree.
This information can be used to help assistive technology users understand the name, role or state of elements.
ARIA is essential when the name, role or state of an element is not natively available.
Go to the Testing ARIA page.
We can see how ARIA attributes affect Chrome’s accessibility tree.
role="button"
Check the <div>
element’s role in the accessibility tree:
We can use ARIA to add semantics to an elements that have none.
role="combobox"
Check the <input>
element’s role in the accessibility tree:
We can use ARIA to improve the semantics of elements.
aria-expanded
Check the <button>
element’s ‘Expanded’ state in the accessibility tree:
We can use ARIA to inform assistive technology users when an element is expanded or collapsed.
aria-invalid
Check the <input>
element’s ‘Invalid User Entry’ value in the accessibility tree:
We can use ARIA to inform assistive technology users when an element is currently invalid.
aria-label
Check the <button>
element’s name in the accessibility tree:
We can use ARIA to improve the accessible names of elements.
aria-live
Check the <div>
element’s ‘Live region’ value in the accessibility tree:
We can use ARIA to inform assistive technology users that a region may contain dynamic content that may change over time.
Chrome’s accessibility tree can be used to show you any ARIA that has been applied and how it will impact HTML elements.
As we saw before, Chrome’s accessibility tree shows the accessible name generated for each element.
The ‘Computed Properties’ panel shows us:
This is very helpful when reviewing the accessibility of elements.
Go to the Input accessible names page.
The examples on this page show very poor accessible naming practices. It is for educational purposes only.
The <input>
element has five accessible names applied. But which one wins?
aria-labelledby
value of ‘Cat’aria-label
value of ‘Dog’<label>
value of ‘Fish’title
value of ‘Rabbit’placeholder
value of ‘Fox’The <input>
element should have an accessible name of ‘Cat’ via the aria-labelledby
attribute.
aria-labelledby
value of ‘Cat’ winsaria-label
value of ‘Dog’<label>
value of ‘Fish’title
value of ‘Rabbit’placeholder
value of ‘Fox’The <input>
element should have an accessible name of ‘Dog’ via the aria-label
attribute.
aria-labelledby
value present.aria-label
value of ‘Dog’ wins<label>
value of ‘Fish’title
value of ‘Rabbit’placeholder
value of ‘Fox’The <input>
element should have an accessible name of ‘Fish’ via the <label>
element.
aria-labelledby
value presentaria-label
value present<label>
value of ‘Fish’ winstitle
value of ‘Rabbit’placeholder
value of ‘Fox’The <input>
element should have an accessible name of ‘Rabbit’ via the title
attribute.
aria-labelledby
value presentaria-label
value present<label>
value presenttitle
value of ‘Rabbit’ winsplaceholder
value of ‘Fox’The <input>
element should have an accessible name of ‘Fox’ via the placeholder
attribute.
aria-labelledby
value presentaria-label
value present<label>
value presenttitle
value presentplaceholder
value of ‘Fox’ winstitle
attributeAs we saw before, the title
can be used to provide an accessible name for some elements.
However, it is very weak and will often be beaten by other methods.
But the title
is very sneaky!
If it loses the accessible name battle, it will try to win the accessible description battle.
Go to the Testing the title
attribute page.
The title
is the only accessible name option and will be used as the accessible name.
<input type="text" title="Add your name">
title
attributeThere is a <label>
present, so the title
will not be used as the accessible name.
However, as there is no other description available, the title
will be used as the accessible description.
<label for="name">Name</label>
<input id="name" type="text" title="Add your name">
<label>
elementtitle
attributeThere is an aria-describedby
present, so the title
will not be used as the accessible description.
In this example, the title
has lost both battles - for accessible name and description.
<label for="name">Name</label>
<span id="aaa">Include your full name</span>
<input id="name" type="text" title="Add your name"
aria-describedby="aaa">
<label>
elementaria-describedby
attributeBy now, you think that the Chrome accessibility tree is amazing.
However, like any tool, it has strengths and weaknesses.
For example, Chrome does not accurately define required
states for some of the more recent form controls.
Go to the Testing the required attribute in Chrome page.
If we inspect the <input type="email">
, the accessibility tree correctly displays:
Required: true
Invalid user entry: false
If we inspect the <input type="search">
, the accessibility tree displays:
Required: Not exposed
Invalid user entry: false
And if we inspect the <input type="date">
, the accessibility tree incorrectly displays:
Required: Not exposed
Invalid user entry: true
Chrome’s accessibility tree is incorrectly displaying information for a range of elements.
While Chrome’s accessibility tree is very useful, it does not replace rigorous accessibility testing.
And it does not replace screen reader testing either.
If you’ve never used Chrome’s accessibility tree, hopefully, this session will give you the confidence and knowledge to give it a go!