Join MDN and developers like you at Mozilla's View Source conference, November 2-4 in Portland, Oregon. Learn more at

Using the slider role


This technique demonstrates how to use the slider role. 

The slider role is used for markup that allows a user to select a value from within a given range. The slider role is assigned to the "thumb," the control that is adjusted to change the value. Typically, another element is styled to visually represent the range of possible valued, and the thumb positioned visually to represent the value within that range. As the user interacts with the thumb, the application must programmatically adjust the slider's aria-valuenow (and possible aria-valuetext) attribute to reflect the current value. See the Examples section below for more information.

Keyboard And Focus

The slider should be keyboard focusable and operable. When the user tabs focus to the slider, it should land on the thumb: the control a mouse user would drag. Arrow keys should operate as follows (localization for right-to-left languages should reverse the direction of the arrows):

Key(s) Action
Right and Up arrows Increase the selected value
Left and Down arrows Decrease the selected value
Page Up and Page Down Optionally increase and decrease the value by a set amount (e.g. by 10 on a range from 0 to 100)

Possible effects on user agents and assistive technology 


Note: Opinions may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative.


Example 1: Simple Numerical Range

In the example below, a simple slider is used to select a value between 1 and 100. The current volume is 60. The application will programmatically update the value of aria-valuenow in response to user input.

<div id="slider-label">Volume</div>
<div class="vol-slider">
  <a href="#" id="vol-handle" class="handle" role="slider" aria-labelledby="slider-label"

Example 2: Text Values

Sometimes, a slider is used to choose a value that is not, semantically, a number. In these cases, the aria-valuetext attribute is used to provide the appropriate text name for the currently selected value. In the example below, the slider is used to select a day of the week.

<div id="slider-label">Weekday:</div>
<div class="day-slider">
  <a href="#" id="day-handle" class="day-slider-handle" role="slider" aria-labelledby="slider-label"

The code snippet below shows a function that responds to user input and updates the aria-valuenow and aria-valuetext attributes:

var dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var updateSlider = function (newValue) {
    var handle = document.getElementById("day-handle");
    handle.setAttribute("aria-valuenow", newValue.toString());
    handle.setAttribute("aria-valuetext", dayNames[newValue]);

Working Examples:


ARIA attributes used


TBD: Add support information for common UA and AT product combinations

Additional resources

Document Tags and Contributors

Contributors to this page: rylan, Sheppy, anastasia, hhillen
Last updated by: rylan,