Languages
[Edit]
EN

HTML - range input

6 points
Created by:
Marley-Marks
442

In this article, we would like to show you how to create and use range input element in HTML.

Quick solution:

// ONLINE-RUNNER:browser;

<label>
  <span>Range: </span>
  <input type="range" name="example-range" min="0" max="10" />
</label>

Screenshot:

Input range element example.
Input range element example.

Practical example

In this example, we use the input element's type="range" attribute to create range input element.

Additionally, we specify the following range input attributes:

  • min - minimum value,
  • max - maximum value,
  • step - specifies the size of each movement (increment or decrement) of the slider control.
// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<body>
  <script>
    
    function handleInput(input) {
    	console.log('Value: ' + input.value);
    }
    
  </script>
  <form>
    <label>
      <span>Range: </span>
      <input type="range" name="example-range" min="0" max="10" step="2" oninput="handleInput(this)" />
    </label>
  </form>
</body>
</html>

References

HTML - input element types

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join