SlideShare a Scribd company logo
Accessible names &
descriptions
How are they calculated?
Some de
fi
nitions
Let’s
fi
rst look at some different terms,
which are sometimes confused:
1. The <label> element.
2. Visible text labels.
3. Accessible names.
4. Accessible descriptions.
1. The <label> element
<!-- LABEL ELEMENT -->
<label>Label text</label>
The <label> element can be used to provide
a visible text label and/or an accessible
name for speci
fi
c form elements.
There are only
fi
ve HTML elements that
should have an associated <label> element:
<!-- INPUT -->
<label for="aaa">Label text</label>
<input id="aaa" type="text">
<!-- SELECT -->
<label for="bbb">Label text</label>
<select id="bbb"></select>
<!-- TEXTAREA -->
<label for="ccc">Label text</label>
<textarea id="ccc"></textarea>
<!-- METER -->
<label for="ddd">Label text</label>
<meter id="ddd"></meter>
<!-- PROGRESS -->
<label for="eee">Label text</label>
<progress id="eee"></progress>
2. Visible text labels
A visible text label is a label that is
presented on-screen as text. Visible labels
can include:
Label text
Form label
Form control
Text <input> with visible text label
Visible text label
Label text
Form control Form label
Radio button with visible text label
Visible text label
Label text
<select> element with visible text label
Value
Choose an option
Form label
Form control
Visible text label
Label text
<textarea> element with visible text label
Form label
Form control
Visible text label
Label text
<meter> element with visible text label
Form label
Form control
Visible text label
Label text
<progress> element with visible text label
Form label
Form control
Visible text label
Button text
Form control
<button> with visible text label
Visible text label
Link text
<a> element with visible text label
Visible text label
<fieldset> element with visible text label via <legend>
Label text
Legend text
Fieldset
Visible text label
<section> element with visible text label via heading
Heading text
Section
Lorem ipsum dolor sit amet,
consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut
labore et dolore magna aliqua.
Visible text label
<table> element with visible text label via <caption>
Fishes
Gold
fi
sh
Guppy
Blue
fi
sh
Frogs
Cane toad
Tree frog
Common frog
Birds
Robin
Kookaburra
Magpie
Types of animal
Caption
Visible text label
3. Accessible names
All accessible objects in the accessibility tree
should have meaningful, accessible names.
These names are used by assistive
technologies to identify the object.
You can see the name assigned to accessible
objects by viewing the accessibility tree.
In the following example, a <button>
element has a text value of “Save”.
<button>Save</button>
Using Chrome’s accessibility tree, we can see
that the computed accessible name for the
<button> is “Save”.
Accessible names & descriptions
Accessible name vs
visual text label
In some cases, the accessibility name
matches the visible text label.
<button>Save</button>
Button visible text label: "Save"
Button accessible name: "Save"
<label for="aaa">First name</label>
<input id="aaa" type="text">
Input visible text label: "First name"
Input accessible name: "First name"
However, it is possible to create an
accessible name that is partially or even
entirely different from the visible text label.
This could be achieved using hidden text, the
aria-labelledby attribute, aria-label
attribute, or even the title attribute.
For example, the accessible name could
include additional content before, after or
before and after the visible text label.
Here’s an example using hidden text:
<button>
<span class="sr-only">Please</span>
Save
</button>
Button visible text label: "Save"
Button accessible name: "Please Save"
<button>
Save
<span class="sr-only">and return</span>
</button>
Button visible text label: "Save"
Button accessible name: "Save and return"
<button>
<span class="sr-only">Please</span>
Save
<span class="sr-only">and return</span>
</button>
Button visible text label: "Save"
Button accessible name: "Please Save and return"
And an example using aria-label:
<button aria-label="Please save">
Save
</button>
Button visible text label: "Save"
Button accessible name: "Please Save"
<button aria-label="Save and return">
Save
</button>
Button visible text label: "Save"
Button accessible name: "Save and return"
<button aria-label="Please save and return">
Save
</button>
Button visible text label: "Save"
Button accessible name: "Please save and return"
However, we should avoid accessible names
that do not contain text from the visible
text label.
<button aria-label="Something else">Save</button>
Button visible text label: "Save"
Button accessible name: "Something else"
<button title="Another thing">Save</button>
Button visible text label: "Save"
Button accessible name: "Another thing”
These two examples could cause confusion
for a range of users, including sighted users
who use screen readers for additional
assistance, as the visible text label does not
match the accessible name at all.
4. Accessible descriptions
In some cases, accessible objects may also
need additional information, to provide
additional context for the element, in the
accessibility tree.
Descriptions can be applied to elements
using the aria-describedby attribute.
You can see the description assigned to
accessible objects by viewing the
accessibility tree.
In the following example, an <input>
element has a visible label of “Name” and a
description of “Use full name”.
The primary element contains the aria-
describedby attribute and the descriptive
text element contains a matching id
attribute.
<label for="aaa">Name</label>
<input id="aaa" type="text" aria-describedby="a1">
<span id="a1">Use full name</label>
Using Chrome’s accessibility tree, we can see
that the computed accessible name for the
<input> is “Use full name”.
Accessible names & descriptions
Notice that the “Description” slot is separate
to the “Name” slot in the accessibility tree.
These two concepts serve totally different
purposes.
It is also possible to hide the descriptive text
element off-screen, so it is only presented to
assistive technologies.
An example where this could be used, is
additional instructions or information for
assistive technologies:
<input type="text" aria-describedby="hint">
<span id="hint" style="display: none;">When
autocomplete results are available use up and down
arrows to review and enter to select.</span>
How are accessible names
and descriptions de
fi
ned?
The names and descriptions are de
fi
ned in
two speci
fi
c W3C speci
fi
cations.
Accessible Name and Description Computation 1.1
https://www.w3.org/TR/accname-1.1/
HTML Accessibility API Mappings 1.0
https://www.w3.org/TR/html-aam-1.0/
These two speci
fi
cation describe how
browsers can determine accessible names
and descriptions for each object as text
strings.
Accessible names and
description for some key
elements
Let’s take a look at how names and
descriptions are calculated for some
example elements.
In each case, the steps are applied in priority
order from highest to lowest.
<input> and <textarea>
elements
This rule is relevant to the following
elements:
<input type="text">
<input type="password">
<input type="search">
<input type="tel">
<input type="url">
<textarea></textarea>
For these elements, the accessible name
would be de
fi
ned in the following order:
1. Use aria-labelledby
2. Otherwise, use aria-label
3. Otherwise, use associated <label> element
4. Otherwise, use title
5. Otherwise, use placeholder
6. Otherwise, there is no accessible name
And the description would be de
fi
ned in the
following order:
1. Use aria-describedby
2. Otherwise, use title
3. Otherwise, there is no accessible description.
The relevant section of the speci
fi
cation:
https://www.w3.org/TR/html-aam-1.0/#input-type-text-input-
type-password-input-type-search-input-type-tel-input-type-url-
and-textarea-element
<a> and <button> elements
In the case of <a> and <button> elements,
the accessible name would be de
fi
ned in the
following order:
1. Use aria-labelledby
2. Otherwise, use aria-label
3. Otherwise, use element’s content
4. Otherwise, use title
5. Otherwise, there is no accessible name
And the description would be de
fi
ned in the
following order:
1. Use aria-describedby
2. Otherwise, use title
3. Otherwise, there is no accessible description.
The relevant sections of the speci
fi
cation:
https://www.w3.org/TR/html-aam-1.0/#button-element
https://www.w3.org/TR/html-aam-1.0/#a-element-with-a-href-
attribute
<img> elements
In the case of <img> elements, the accessible
name would be de
fi
ned in the following
order:
1. Use aria-labelledby
2. Otherwise, use aria-label
3. Otherwise, use alt
4. Otherwise, use title
5. Otherwise, there is no accessible name
And the description would be de
fi
ned in the
following order:
1. Use aria-describedby
2. Otherwise, use title
3. Otherwise, there is no accessible description.
The relevant section of the speci
fi
cation:
https://www.w3.org/TR/html-aam-1.0/#img-element
<
fi
eldset> elements
In the case of <fieldset> elements, the
accessible name would be de
fi
ned in the
following order:
1. Use aria-labelledby
2. Otherwise, use aria-label
3. Otherwise, use <legend>
4. Otherwise, use title
5. Otherwise, there is no accessible name
And the description would be de
fi
ned in the
following order:
1. Use aria-describedby
2. Otherwise, use title
3. Otherwise, there is no accessible description.
The relevant sections of the speci
fi
cation:
https://www.w3.org/TR/html-aam-1.0/#
fi
eldset-and-legend-
elements
<table> elements
In the case of <table> elements, the
accessible name would be de
fi
ned in the
following order:
1. Use aria-labelledby
2. Otherwise, use aria-label
3. Otherwise, use <caption>
4. Otherwise, use title
5. Otherwise, there is no accessible name
And the description would be de
fi
ned in the
following order:
1. Use aria-describedby
2. Otherwise, use <caption> if not used for name.
3. Otherwise, use title
4. Otherwise, there is no accessible description.
The relevant sections of the speci
fi
cation:
https://www.w3.org/TR/html-aam-1.0/#
fi
eldset-and-legend-
elements
Stepping through the
Computation
For those interested, I can also do a walk-
through of the Accessible name and
description computation.
This is an extremely simpli
fi
ed version of the
steps. Otherwise we’d be here all day.
Compute the text alternative for the current
node:
Step A.
If the current node is hidden and is not
directly referenced by aria-labelledby or
aria-describedby, nor directly referenced
by a text alternative element (e.g. label in
HTML) or attribute, return the empty string.
The following examples would meet this rule
and return an empty string:
<input type="text" hidden>
Input accessible name: Empty string
<label>Name</label>
<input type="text" hidden>
Input accessible name: Empty string
The following example would not meet this
rule and would therefore not return an
empty string:
<label for="aaa">Name</label>
<input id="aaa" type="text" hidden>
Input accessible name: "Name"
<section aria-labelledby="a" hidden>
<h3 id="a">Contact details</h3>
</section>
Section accessible name: "Contact details"
Step B.
Otherwise, if computing a name, and the
current node has an aria-labelledby
attribute that contains at least one valid
IDREF, process its IDREFs in the order they
occur.
In the following example an <input>
element has an aria-labelledby attribute
with two space-separated values, A and B.
<input type="text" aria-labelledby="a b">
Within the document there are two
elements with ID values of A and B.
<input type="text" aria-labelledby="a b">
<p id="a">Help text</p>
<p id="b">Error message</p>
The contents of these elements becomes the
accessible name for the <input>.
The accessible name is computed based on
the order the ID contents are de
fi
ned within
the aria-labelledby attribute.
<input type="text" aria-labelledby="a b">
<p id="a">Help text</p>
<p id="b">Error message</p>
Accessible name="Help text Error message"
Step C.
Otherwise, if computing a name, and if the
current node has an aria-label attribute
whose value is not the empty string, return
the value of aria-label.
In the following example, the <button>
element has an aria-label, which becomes
the accessible name.
<button aria-label="Close modal">X</button>
Accessible name="Close modal"
Step D.
Otherwise, if the current node's native
markup provides an attribute (e.g. title) or
element (e.g. HTML label) that de
fi
nes a
text alternative, return that alternative in
the form of a
fl
at string, unless the element is
marked as presentational
role="presentation" or role="none".
In the following example, the <label> is
explicitly associated with the <input> using
matching FOR and ID values.
This means that the <label> element
provides a text alternative for the <input>
that can be used as an accessible name.
<label for="suburb">Your suburb</label>
<input id="suburb" type="text">
Accessible name="Your suburb"
In the following example, the <img> includes
an alt attribute that contains a text string.
This means that the alt attribute provides a
text alternative for the <img> that can be
used as an accessible name.
<img alt="Round ball" src="ball.png">
Accessible name="Round ball"
In the following example, a <button>
element does not contain a text string, but
does include a title attribute that contains
a text string.
This means that the title attribute
provides a text alternative for the <button>
that can be used as an accessible name.
<button title="Close"></button>
Accessible name=“Close"
Step E.
We’ll skip over Step E to avoid complexity.
Step F.
Otherwise, if the current node's role allows
name from content… return the accumulated
text.*
(* Extremely simpli
fi
ed version)
Some ARIA role attributes allow “Name
from content”.
This means that the text within these
elements becomes the accessible name.
The full list of “Roles Supporting Name from
Content”:
https://www.w3.org/TR/wai-aria/#namefromcontent
In the following example, an element has
been given a role of button and therefore
can produce an accessible name.
<div role="button">Help</div>
Accessible name="Help"
Step G.
Otherwise, if the current node is a Text node,
return its textual contents.
In the following example, the link text is the
accessible name.
<a href="#">Hello world</a>
Accessible name="Hello world"
After all steps are completed, the total
accumulated text is used as the accessible
name or accessible description of
the element that initiated the computation.
The End

More Related Content

PDF
A deep dive into accessible names
PDF
What are accessible names and why should you care?
DOCX
Accessible Name and Description calculation
PPTX
Siteimprove TechTalk: Demystifying Accessible Names
PPTX
HTML5 Accessibility
PPTX
Resistance is futile: Start writing accessible websites now!
PPTX
Accessibility and universal usability
PPTX
How you can start building accessible websites today (... and why!)
A deep dive into accessible names
What are accessible names and why should you care?
Accessible Name and Description calculation
Siteimprove TechTalk: Demystifying Accessible Names
HTML5 Accessibility
Resistance is futile: Start writing accessible websites now!
Accessibility and universal usability
How you can start building accessible websites today (... and why!)

Similar to Accessible names & descriptions (20)

PDF
YUI + Accessibility: Welcome the whole world
PPT
HTML5 Accessibility CSUN 2012
PDF
HTML5 and ARIA accessibility - Bangalore 2013
PPTX
Introduction to accessibility
PDF
P.S. I love you
PDF
Accessibility
PPTX
DOM and Accessibility API Communication
PDF
Modern web development and accessibility (Christina Papadimitriou, Nadia Mark...
PPTX
Accessible web applications
PPTX
Web Accessibility in Drupal
PDF
Building a better, accessible web
PPTX
Web accessibility
PDF
[BlinkOn17] Accessible name computation update
PPTX
A Primer on Web Accessibility for Teams
PPTX
Web accessibility - WAI-ARIA a small introduction
PPTX
Accessibility with Single Page Apps
PDF
Tech Headline - Using WAI-ARIA & HTML5: Techniques to solve accessibility pro...
PPTX
Accessibility-Oriented Paradigm for Designing UI
PPT
How To Build An Accessible Web Application - a11yBos
PDF
WAI-ARIA An introduction to Accessible Rich Internet Applications / AccessU 2018
YUI + Accessibility: Welcome the whole world
HTML5 Accessibility CSUN 2012
HTML5 and ARIA accessibility - Bangalore 2013
Introduction to accessibility
P.S. I love you
Accessibility
DOM and Accessibility API Communication
Modern web development and accessibility (Christina Papadimitriou, Nadia Mark...
Accessible web applications
Web Accessibility in Drupal
Building a better, accessible web
Web accessibility
[BlinkOn17] Accessible name computation update
A Primer on Web Accessibility for Teams
Web accessibility - WAI-ARIA a small introduction
Accessibility with Single Page Apps
Tech Headline - Using WAI-ARIA & HTML5: Techniques to solve accessibility pro...
Accessibility-Oriented Paradigm for Designing UI
How To Build An Accessible Web Application - a11yBos
WAI-ARIA An introduction to Accessible Rich Internet Applications / AccessU 2018
Ad

More from Russ Weakley (20)

PDF
Accessible chat windows
PDF
How to build accessible UI components
PDF
What is WCAG 2 and why should we care?
PDF
Accessible states in Design Systems
PDF
Creating accessible modals and autocompletes
PDF
Building an accessible progressive loader
PDF
Accessibility in Design systems - the pain and glory
PDF
Accessible Inline errors messages
PDF
Accessible Form Hints and Errors
PDF
What is accessibility?
PDF
Accessibility in Pattern Libraries
PDF
Accessibility in pattern libraries
PDF
Building an accessible auto-complete - #ID24
PDF
Building an accessible auto-complete
PDF
Creating Acessible floating labels
PDF
Creating an Accessible button dropdown
PDF
Creating a Simple, Accessible On/Off Switch
PDF
Accessible custom radio buttons and checkboxes
PDF
Deep Dive into Line-Height
PDF
Building Accessible Web Components
Accessible chat windows
How to build accessible UI components
What is WCAG 2 and why should we care?
Accessible states in Design Systems
Creating accessible modals and autocompletes
Building an accessible progressive loader
Accessibility in Design systems - the pain and glory
Accessible Inline errors messages
Accessible Form Hints and Errors
What is accessibility?
Accessibility in Pattern Libraries
Accessibility in pattern libraries
Building an accessible auto-complete - #ID24
Building an accessible auto-complete
Creating Acessible floating labels
Creating an Accessible button dropdown
Creating a Simple, Accessible On/Off Switch
Accessible custom radio buttons and checkboxes
Deep Dive into Line-Height
Building Accessible Web Components
Ad

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Cell Types and Its function , kingdom of life
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Basic Mud Logging Guide for educational purpose
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Institutional Correction lecture only . . .
PDF
RMMM.pdf make it easy to upload and study
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
Module 4: Burden of Disease Tutorial Slides S2 2025
Cell Types and Its function , kingdom of life
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
STATICS OF THE RIGID BODIES Hibbelers.pdf
Supply Chain Operations Speaking Notes -ICLT Program
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Microbial diseases, their pathogenesis and prophylaxis
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Basic Mud Logging Guide for educational purpose
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Final Presentation General Medicine 03-08-2024.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPH.pptx obstetrics and gynecology in nursing
Computing-Curriculum for Schools in Ghana
Institutional Correction lecture only . . .
RMMM.pdf make it easy to upload and study
Abdominal Access Techniques with Prof. Dr. R K Mishra
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pharmacology of Heart Failure /Pharmacotherapy of CHF
102 student loan defaulters named and shamed – Is someone you know on the list?

Accessible names & descriptions