Buttons with same name
A descriptive and unique accessible name helps users to understand the purpose of the element.
NOTE:
- New to accessibility or uncertain of requirements, it will be helpful to review all sections below.
- Already familiar with requirements, skip to the “Working Example” section for sample HTML, CSS and JavaScript (when needed), along with a working demo.
- Buttons MUST have a descriptive and unique accessible name.
-
The accessible name SHOULD contain the visual text if available for the button.
Note: If there is no visual label provided for the button, the accessible name can be provided as per the purpose. - The visible button text MUST meet the text contrast requirement.
- The visible text MUST be at least 4.5:1 against the background color if it’s a standard text in default, focused and hover state.
- The minimum contrast requirement ratio of 3:1 for the large text or text with 14pts and bold MUST be met in default, focused and hover state.
- The contrast requirement of 3:1 ratio MUST be met with the adjacent colors for the custom focus indicator if used for the buttons.
- The contrast ratio requirement of 3:1 MUST be met with the adjacent colors for the image buttons in default, focused and hover state.
- The button text CAN be made descriptive and unique to convey the purpose.
- The title attribute CAN be used to provide a descriptive and unique accessible name.
-
An off-screen button text CAN be provided to make the accessible name descriptive
and unique.
- CSS can be used to place the text off-screen. For more information on placing text off-screen, visit https://css-tricks.com/comparing-various-ways-to-hide-things-in-css/
-
If an image is used to identify the buttons, then a textual description MUST be
defined for the image buttons.
-
If the image is defined using
<img>
element, use an alt attribute with descriptive value. -
If the image is defined using
<svg>
element, userole="img"
andaria-label
attribute to provide a role and an accessible name for the element.
Note: Providing ARIA based role and attribute on SVG image ensures robust support across different environments.
-
If the image is defined using
Example,
<!-- Descriptive and Unique button text -->
<button>Explore more about organization</button>
...
<button>Explore more about policies</button>
<!-- title attribute on button -->
<button title="Explore more about organization">Explore more</button>
...
<button title=" Explore more about policies">Explore more</button>
<!-- off-screen button text -->
<button>Explore more<span class="visually-hidden"> about organization</span></button>
...
<button>Explore more<span class="visually-hidden"> about policies</span></button>
<!-- CSS clipping technique for placing the text off-screen -->
<style>
.visually-hidden:not(:focus):not(:active) {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
</style>
ARIA approach CAN be used if using HTML implementation is not possible.
-
aria-labelledby
attribute CAN be used to associate the visual text with the button by referencing the id attribute of visual text container or visually hidden text container and the button itself.-
Concatenation of multiple pieces of text to form a name is possible through this attribute by
referencing the respective
id
attribute values. - While concatenation, the order of
id
attribute value is important. -
id
attribute values SHOULD be present in the same HTML document. -
It CAN be specified in case of design constraint as well wherein an
additional visual text cannot be added for the button.
Example,
<h2 id="org">Organization</h2> ... <button id="primary" aria-labelledby="primary org">Explore More <span class="visually-hidden"> about </span></button>
-
Concatenation of multiple pieces of text to form a name is possible through this attribute by
referencing the respective
-
Note: If both button text and
aria-labelledby
oraria-label
andaria-labelledby
or button text,aria-label
andaria-labelledby
are present, thearia-labelledby
will take precedence to convey the accessible name of the button. -
aria-label
attribute CAN be used to define a label for the button that does not have supporting visual label. - It’s a challenge for internationalization because its value will not get translated and will require manual updating.
- It’s also a challenge for labelling wherein the labels must be updated as these are hardcoded values.
-
It’s not visible on-screen so ONLY helps assistive technology users such as screen reader
users.
Example,
<button aria-label="Explore more about organization">Explore More</button>
-
aria-describedby
attribute CAN be used to associate the additional information with the respective button by referencing the id attribute of visual text container or visually hidden instruction text container. -
This attribute must NOT be used for labelling a form control.
Example,
<h2 id="org">Organization</h2> ... <button id="primary" aria-describedby="primary org">Explore More <span class="visually-hidden"> about </span></button>
A well-defined button with unique and descriptive name benefits majorly the below users.
- People with cognitive disabilities
- People with visual disabilities
- People using speech input
<div class="row">
<div class="column">
<h2 id="Learners-heading">Learners</h2>
<p>
<span>
Find everything you need to help you with your studies and in
the format you want.
</span>
<span id="Learners-dots">...</span>
<span id="Learners-more">
We believe that every learning opportunity is a chance for a
personal breakthrough. That’s why our c.20,000 Pearson
employees are committed to creating vibrant and enriching
learning experiences designed for real-life impact. We are the
world’s leading learning company, serving customers in
nearly 200 countries with digital content, assessments,
qualifications, and data. For us, learning isn’t just what
we do. It’s who we are.
</span>
</p>
<button class="more_btn" onclick="toggleShowMore('Learners')" id="Learners-explore-link" aria-labelledby="Learners-explore-link Learners-heading">
Show more<span class="sr-only">about the</span>
</button>
</div>
<div class="column">
<h2 id="educators-heading">Educators</h2>
<p>
<span>
Whether planning a lesson or training staff, we have the
material to help you.
</span>
<span id="educators-dots">...</span>
<span id="educators-more">
Students explore what’s possible at Pearson Online Academy
with a personalized online education that creates opportunities.
Our accredited college preparatory program gives students the
flexibility to focus on their interests and learn from anywhere
in the world with a high-quality curriculum that meets rigorous
U.S. education standards.
</span>
</p>
<button class="more_btn" onclick="toggleShowMore('educators')" id="educators-explore-link" aria-labelledby="educators-explore-link educators-heading">
Show more<span class="sr-only">about the</span>
</button>
</div>
<div class="column">
<h2 id="practitioners-heading">Practitioners</h2>
<p>
<span>
From clinical diagnostics to professional assessment and
admission testing, find what you need
</span>
<span id="practitioners-dots">...</span>
<span id="practitioners-more">
We use our knowledge, experience and technology to deliver high
quality, digital learning products to more people around the
world than ever before. We do it because we know that when we
demonstrate the value of learning, we demonstrate the value of
our business and transform lives.
</span>
</p>
<button class="more_btn" onclick="toggleShowMore('practitioners')" id="practitioners-explore-link" aria-labelledby="practitioners-explore-link practitioners-heading">
Show more<span class="sr-only">about the</span>
</button>
</div>
</div>
.column {
width: 100%;
padding: 10px;
box-sizing: border-box;
border-top: 6px solid;
border-color: #0086b1;
}
@media (min-width: 768px) {
.column {
width: 30%;
float: left;
margin: 10px;
}
}
@media (max-width: 767px) {
.row {
display: flex;
flex-direction: column;
}
}
#Learners-more,
#educators-more,
#practitioners-more {
display: none;
}
.more_btn {
outline: none;
background: transparent;
border: none;
font-size: 1rem;
text-transform: lowercase;
color: blue;
}
.more_btn:focus { border: 1px solid; }
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
function toggleShowMore(section) {
var dots = document.getElementById(section + '-dots');
var readMore = document.getElementById(section + '-more');
var openBtn = document.getElementById(section + '-explore-link');
if (dots.style.display === 'none') {
dots.style.display = 'inline';
openBtn.innerHTML = 'Show moreabout the';
readMore.style.display = 'none';
readMore.removeAttribute('tabindex');
openBtn.focus();
} else {
dots.style.display = 'none';
openBtn.innerHTML = 'Show lessabout the';
readMore.style.display = 'inline';
readMore.setAttribute('tabindex','-1');
readMore.focus();
}
}
Learners
Find everything you need to help you with your studies and in the format you want. ... We believe that every learning opportunity is a chance for a personal breakthrough. That’s why our c.20,000 Pearson employees are committed to creating vibrant and enriching learning experiences designed for real-life impact. We are the world’s leading learning company, serving customers in nearly 200 countries with digital content, assessments, qualifications, and data. For us, learning isn’t just what we do. It’s who we are.
Educators
Whether planning a lesson or training staff, we have the material to help you. ... Students explore what’s possible at Pearson Online Academy with a personalized online education that creates opportunities. Our accredited college preparatory program gives students the flexibility to focus on their interests and learn from anywhere in the world with a high-quality curriculum that meets rigorous U.S. education standards.
Practitioners
From clinical diagnostics to professional assessment and admission testing, find what you need ... We use our knowledge, experience and technology to deliver high quality, digital learning products to more people around the world than ever before. We do it because we know that when we demonstrate the value of learning, we demonstrate the value of our business and transform lives.