References

Beginner-friendly references for web development, with live, editable examples.

The HTML aria-roledescription attribute

ARIA Accessibility
In short

The aria-roledescription attribute sets a human-readable role name, such as slide in place of group. It changes how the role is presented, not what the role is. Limit it to non-interactive containers and more specific widget descriptions, and avoid it when you can.

Overview

The aria-roledescription attribute defines a human-readable, author-localized description for the role of an element. Some assistive technologies, such as screen readers, present an element's role, and this value is what they should use for it. The element's real role stays the same.

Its use should stay limited to clarifying the purpose of a non-interactive container, such as a group or region, or to describing a widget more specifically.

The element should also have a valid role, explicit or implicit, and the value should hold real text, not an empty or whitespace-only string.

The rule is firmer on the generic role, where the attribute is prohibited, and WAI-ARIA says authors must not specify a prohibited property. That covers a plain <div> or <span>, and a <section> with no name, whose role is also generic.

The browser rules differ between versions. WAI-ARIA 1.2 says browsers must not expose an empty or whitespace-only value, while the 1.3 draft says "undefined or the empty string". Chrome and Firefox both keep a whitespace-only value, and on a plain div only Firefox keeps any value.

Syntax

<section aria-roledescription="slide" aria-labelledby="t1">
  <h2 id="t1">Quarterly report</h2>
</section>

Values

Value
A string.

Example

Live example
<p>Go to the next slide, then switch the language.</p>
<section id="slide" lang="en" aria-roledescription="slide" aria-labelledby="title">
  <h2 id="title">Quarterly report</h2>
</section>
<button id="next" type="button">Next slide</button>
<button id="language" type="button">Spanish</button>
<p role="status" id="out"></p>
<script>
const copy = {
  en: { role: 'slide', titles: ['Quarterly report', 'Next steps'], other: 'Spanish' },
  es: { role: 'diapositiva', titles: ['Informe trimestral', 'Siguientes pasos'], other: 'English' }
};
const slide = document.getElementById('slide');
let lang = 'en';
let index = 0;
function show() {
  slide.lang = lang;
  slide.setAttribute('aria-roledescription', copy[lang].role);
  document.getElementById('title').textContent = copy[lang].titles[index];
  document.getElementById('language').textContent = copy[lang].other;
  document.getElementById('out').textContent = 'aria-roledescription is ' + copy[lang].role + ', and the role is still region.';
}
document.getElementById('next').addEventListener('click', function () {
  index = index === 0 ? 1 : 0;
  show();
});
document.getElementById('language').addEventListener('click', function () {
  lang = lang === 'en' ? 'es' : 'en';
  show();
});
show();
</script>

Best practices

  • Reach for aria-roledescription last. Misuse may make it harder for users to understand or interact with an element, and the interaction can often be broken into pieces that have relevant roles.
  • Leave the role word out of the accessible name, so a slide is labeled Quarterly report rather than Quarterly report slide.
  • Choose widget descriptions that keep the control recognizable. A value like download button still says button, while a bare word like escape hides what the control is.
  • If no role fits, use role="application" with a localized role name. Some assistive technologies reach only focusable elements there, so tie static text to one, for example with aria-describedby.

Frequently asked questions

What does the aria-roledescription attribute change?
The aria-roledescription attribute changes the role name that assistive technology presents. A screen reader user may hear Quarterly Report, slide rather than the vaguer Quarterly Report, region.
Does aria-roledescription change keyboard or screen reader commands?
No, aria-roledescription shouldn't change functionality. A command that moves to the next region or button should still reach elements that have a custom role description.
Who localizes aria-roledescription?
You do, because aria-roledescription is author-localized and overrides how assistive technology localizes the role name. It's a translatable attribute, so translate the value whenever the page is localized.
Should a button ever have an aria-roledescription?
Yes, aria-roledescription can give a widget a more specific description, such as attachment button. The value is exposed, and the element's role stays button.
How is aria-roledescription used in a carousel?
A basic carousel can use aria-roledescription at two levels. The container gets the value carousel, and each slide gets role group with the value slide.
Is an aria-roledescription always presented?
No, an aria-roledescription isn't presented every time. The 1.3 draft says role descriptions might not be conveyed on certain elements, depending on the assistive technology and verbosity settings.