9

Just a simple question

When I tried to create a carousel, I noticed many sample codes are:

<div class="carousel-inner" role="listbox">

In the above code, what does role="listbox" do? Please give me an insight.

kukkuz
  • 41,512
  • 6
  • 59
  • 95

1 Answers1

12

role="listbox" is used for accessibility purposes. It identifies to a screen-reader or other assistive technology device that this is an element that allows a user to choose one or more options, such as images in a carousel.

You should also add role="option" to each slide.

see here for more information: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_listbox_role

Nate K
  • 240
  • 4
  • 11