Skip to main content
No Result Found

accessible-name-carousel

Ensure that carousel elements have an accessible name.

Rule Severity : Serious

All interactive carousel elements must have an accessible name.

Pagination and navigation items in carousels declared using non-standard elements like divs break the accessible-name-carousel rule if they don’t have accessible names. Accessible names ensure that assistive technologies, like screen readers, can accurately identify and communicate interactive elements to users. Users of assistive technologies can navigate and interact with carousels on your website effectively if such carousel elements have accessible names.

You can use the aria-label attribute to describe the purpose of interactive elements in carousels. Also, you can use the aria-labelledby attribute to name visible text elements in carousels.

Example

In the following example code, the ‘prev’ and ‘next’ elements don’t have accessible names. This code breaks the accessible-name-carousel rule as assistive technologies like screen readers cannot identify the interactive elements.

Incorrect Sample Code
Copy icon Copy

The following sample code corrects the issue in the earlier example by adding inner texts and aria-label:

Correct Sample Code - aria-label
Copy icon Copy

You can also solve the issue by using the aria-labelledby attribute as follows:

Correct Sample Code - aria-labelledby
Copy icon Copy

How to fix?

Follow these steps to fix any violations in the accessible-name-carousel rule:

  • Use the aria-label attribute on non-standard interactive elements of a carousel to describe its purpose. For example, you can name the carousel arrows as ‘previous arrow’ and ‘next arrow’.
  • If a visible label exists, use the aria-labelledby attribute with the element’s id containing the visible text, to describe its purpose.
  • Add a title attribute that describes the element’s purpose.
  • Add inner text to interactive elements whenever possible.
  • Set the role of non-interactive elements as “none” or “presentation”.

Reference

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle