Format Code Now
/
Web & markupHTML Range Input Generator Next: HTML Strikethrough Generator ›

HTML Range Input Generator

WM-38

Type a label and the limits and copy a labelled range slider. Turn on the output option to show the chosen number next to it.

Runs in your browser. Nothing is uploaded.

Key: value lines (label: is required; also name:, min:, max:, step:, value:, list:, disabled:)

HTML

How to use it

  1. Write label:, then name:, min:, max:, step: and value: as needed.
  2. Leave the live output option on if people should see the number.
  3. Copy the label and input.
  4. Style the slider with CSS.

Defaults and what is checked

A range input with no attributes runs from 0 to 100 in steps of 1, and starts at the midpoint of the range. The tool checks your numbers against those defaults when you leave a line out: min must be lower than max and value must sit between them. step can be a positive number or the word any, which allows finer values. All values are written exactly as you typed them.

Showing the value

A slider does not show a number on its own, and it is hard to hit an exact value on a touch screen. With the output option on, the tool adds an output element tied to the slider by for and id, and a short oninput handler that copies the slider value into it as you drag. If you need exact entry, add a number input too. Tick marks come from a datalist linked by the list: line, and you write that datalist yourself.

Error messages and what to do

MessageWhat it meansFix
"min:" must be smaller than "max:".The slider range is empty or reversed.Make min lower than max.
"value:" must be between min and max.The starting value is outside the range.Change the value or the limits.

Questions people ask

How do I make a slider in HTML?

Use an input of type range with a label, a min and a max. Add step for the increment. Use an output element if the person needs to see the current number.

What are the default min and max of a range input?

min is 0 and max is 100, with a step of 1. The slider starts at the midpoint unless a value is set. Setting them yourself is clearer, and the tool checks them against each other before it writes anything.

How do I show the value of a range slider?

Add an output element and update it when the slider changes. The generated handler sets the output value from the slider on each input event.

Can a range input have decimal values?

Yes. Set step to a decimal such as 0.1, or to any. Keep in mind that decimals shown as typed may look different after the browser rounds to the step.

Is a range slider accessible?

It can be used with arrow keys and is announced as a slider, with the label as its name. Show the value in text, and avoid a slider when exact numbers matter.

About this tool

Writes a label and an input of type range. When you leave them out, browsers use min 0, max 100 and a step of 1, and this tool checks your values against those defaults: min below max, value between them. step can be a number or any. With the output option on, the tool adds an output element tied to the slider with a short oninput handler, so the number updates as you drag. A range input has no text box, so it is hard to set an exact value by touch; consider a number input as well when exact values matter. The tool writes no styling. Optional lines: id:, class:, title:, lang:, data-* and aria-*.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.