Show This is a handy generator that will help you style the html input range tag. You will be able to style all aspects of the input range tag and see the changes in the preview box below. Once you are happy with the style, simply copy and paste the generated css code into your project. If you need a bit of help to style the input tag, just select from one of our preset designs to get you started. Style Input Range Preview Thumb Properties Thumb Color Thumb Height: 30px Thumb Width: 15px Thumb Radius: 5px Color Thumb Border Width: 1px Shadow Color Thumb Shadow Size: 1px Thumb Shadow Blur: 1px Track Color Track Height: 10px Track Radius: 5px Track Border Color Track Border Width: 1px Track Shadow Color Track Shadow Size: 1px Track Shadow Blur: 1px Presets Click on the thumb to update input range style. Share this PageIf you have enjoyed using CSSPortal, please consider sharing this page with other users, just click on your preferred social media link or copy the webpage from the link below. URL To style the range input with CSS you’ll need to apply styles to two pseudo-elements: Contents of the article:
The The default browser styling for this element is very basic and doesn’t provide enough information to the user which might confuse one. Also, the appearance of the range input element is different across browsers. Range input HTML: Range input appearance on different browsers: Luckily there are ways you can improve that using nothing but native CSS and JavaScript. CSS selectors for the range inputThe range input widget consists of two parts the thumb and the track. Each one of these parts has its own pseudo-class selector for styling with a vendor suffix for cross-browser support. Thumb:
Track:
To indicate the selected value, we can add a color from the start of the track up until the thumb. To do that we can use the Improving usabilityThe default range input doesn’t specify any values selected. Which makes it hard for users to understand what value is currently selected. While the hash marks and labels on the range input are a great way to aid users visually, this feature is yet to become available. However, there are a few ways you can improve that with some additional HTML and JavaScript:
Specify the output element to display the selected valueThe
Specify the number input that is synced to the range inputTo take it a step further you can add a number input next to the range element. That way the user will see the selected value and will have an option to modify it via the number input, which can be a better experience especially for mobile users.
A sprinkle of JavaScriptTo finalize we’ll need some JavaScript code to make it all work. The But to update the selected area of the range input we need to calculate the ratio and apply that value to the input
Custom range input DemoFull example with all the code can be seen on CodePen: See the Pen Range Input with values (Pure HTML, CSS, JS) by Tippingpoint Dev (@tippingpointdev) on CodePen. |