Range slider (type="range")

HTML Living Standard

Let the user choose an approximate number with a slider. Add an adjacent readout when the exact value matters.

On this page

Attributes and behavior

Value or syntaxWhat it does
min="0" / max="100"The default bounds are 0 and 100.
step="5"Moves in increments of five.
value="25"Sets the initial slider position.

Try the example

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Range slider</title>
  <style>
form { display: grid; gap: 12px; justify-items: start; } output { display: block; margin-top: 10px; }
  </style>
</head>
<body>
<form id="demo">
  <label>Volume <input type="range" name="volume" min="0" max="100" step="5" value="25" oninput="level.value = this.value"></label>
<output id="level">25</output>
  <button type="submit">Check</button>
</form>
<output id="response"></output>
  <script>
const form = document.querySelector('#demo');
form.addEventListener('click', event => {
  const submitter = event.target.closest('[type="submit"], [type="image"]');
  if (!submitter) return;
  event.preventDefault();
  if (!form.noValidate && !submitter.formNoValidate && !form.reportValidity()) return;
  const values = new FormData(form, submitter);
  document.querySelector('#response').textContent =
    'Passed validation. Fields received: ' + [...values.keys()].join(', ');
});
  </script>
</body>
</html>

What to expect Move the slider and watch its numeric value update in increments of five.

Official references