HTML: Input Range Slider

By Xah Lee. Date: . Last updated: .

The input range is used for user input of a numerical value, within a min max range.

Here's a input range:

Here's the HTML code:

<input id="ra29215" type="range">
<span class="display_31907" id="display_area_17846"></span>

Here's the JavaScript code to display the value:

const sld = document.getElementById("ra29215");

const da1 = document.getElementById("display_area_17846")

da1.textContent = sld.value;

sld.addEventListener("input", ((x) => { da1.textContent = sld.value;}) , false);

By default, the range is 0 to 100.

Specify Range, Step, Default Value

<input id="input_range_2_73496" type="range" max="1" step="0.1" value="0.7" >

Important Attributes

Slider with Markers

Here is a example of slider with markers, using the “list” attribute.

<input type="range" min="-50" max="50" value="0" step="1" list="marks">
<datalist id="marks">
  <option value="0">
  <option value="-30">
  <option value="30">


You can add labels to the markings.

this is not currently supported by major browsers.

<input id="input_range_4_33754" type="range" list="a-values">
<datalist id="a-values">
 <option value="10" label="Low">
 <option value="90" label="High">

Web Scripting Overview

  1. Browser Window Object, DOM
  2. Intro to Event-Based Programing
  3. JavaScript Load Order

DOM How-To

  1. Basic DOM Methods
  2. Get Element by ID, Tag, Name, Class, CSS
  3. Change CSS
  4. Change Node Content
  5. Create/Insert Node
  6. Remove Node
  7. Get Attribute Value
  8. Set Attribute Value
  9. Remove Attribute
  10. List/Add/Remove Class Attribute
  11. Add/Remove Event Handler
  12. Navigate DOM Tree
  13. Node Type, Name, Value


  1. Button
  2. Input Text Field
  3. Password Text Field
  4. Textarea
  5. Radio Button
  6. Checkbox
  7. Selection, Popup Menu
  8. Input Range Slider
  9. Color Picker

Web Scripting Examples

  1. Disable Right Click
  2. document.write
  3. Image Rollover
  4. Pop-up New Window
  5. Digital Clock
  6. Stopwatch
  7. Fade a Element
  8. How to Create Tooltip
  9. Falling Snow Effect
  10. Box Following Scroll

Web Scripting Misc

  1. Web Cookies
  2. Web Storage
  3. DOM: Open URL
  4. Encode URL, Escape String
  5. Browser Info, Navigator Object
  6. Get URL (window.location)
  7. Find Window Width
  8. Find Element Width
  9. WebSocket
  10. Value of “this” in Event Handler
  11. Event Delegation
  12. Get Current Script Tag
  13. insertAfter Element
  14. Randomize List
  15. create Document Fragment
  16. innerHTML, nodeValue, textContent, innerText?
  17. What is Live Object
  18. NodeList vs HTMLCollection
  19. Whitespace Nodes


  1. jQuery Basics
  2. jQuery() vs querySelectorAll()
  3. Write JQuery Plugin


Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS in Depth
  4. JS Object Ref
  5. DOM Scripting
  6. SVG
  7. Blog