Simple Price Range Slider With HTML CSS and JavaScript

In this tutorial we will see how to make a Simple Price Range Slider With HTML CSS and JavaScript. Pure CSS and Vanilla JavaScript is used to make this price range slider, CSS code and JavaScript code is given.

HTML Code

Take a look at the HTML code given below.

<div class="priceSlider">
<h1>Price Range:</h1>
<p>Move Slider to choose the price range.</p> 
    
<div class="min-max">
 <div class="min">
     <label>Min</label><span id="min-value"></span>
 </div>
 <div class="max">
     <label>Max</label><span id="max-value"></span>
 </div>     
</div> 
    
<div class="min-max-range">
<input type="range" min="0" max="5000" value="2000" class="range" id="min">
<input type="range" min="5001" max="10000" value="8000" class="range" id="max">      
</div>    
    
<div style="clear: both;"></div>    
</div> 

CSS Code

CSS code is given below.

<style>      
body
{
margin: 0;
padding: 0;
background-color: #00E673;
font-family: 'Barlow Condensed' , sans-serif;
display: flex;
min-height: 100vh;
align-items: center;
justify-content: center;    
}
.priceSlider
{
width: 200px;
background-color: #fff;
border-radius: 5px;
padding: 10px 20px;
box-shadow: 0px 0px 3px 1px #888;    
}
.priceSlider h1
{
font-size: 17px;
font-weight: bold;
}
.priceSlider p
{
font-size: 10px;
margin-top: 20px;    
}
.min-max label
{
font-size: 14px;
float: left;
margin-right: 5px;
line-height: 1.6;    
}
.min
{
float: left;    
}
.max
{
float: right;    
}
.min-max
{
width: 90%;
max-width: 200px;
margin: 0 auto;
padding: 25px 0px 15px 0px;    
}
.min-max span
{
font-size: 10px;
text-align: center;
display: inline-block;
width: 30px;
border: 1px solid #dedede;    
}
.min-max-range
{
padding: 30px 0px 20px 0px;    
}
.range
{
-webkit-appearance:none;
appearance:none;
width: 50%;
height: 10px;
max-width: 400px;
background-color: #dedede;
margin: 0;
padding: 0;
outline: none;
float: left;    
}
.range::-webkit-slider-thumb
{
-webkit-appearance:none;
appearance:none;
background-color: #0070BF;
height: 10px;
width: 10px;
border-radius: 50%;
cursor: pointer;
}
.range::moz-range-thumb
{
-webkit-appearance:none;
appearance:none;
background-color: #0070BF;
height: 10px;
width: 10px;
border-radius: 50%;
cursor: pointer;
}
</style>           

JavaScript Code

Take a look at the Pure JavaScript Code given below.

<script>
var minSlider = document.getElementById('min');
var maxSlider = document.getElementById('max');

var outputMin = document.getElementById('min-value');
var outputMax = document.getElementById('max-value');

outputMin.innerHTML = minSlider.value;
outputMax.innerHTML = maxSlider.value;

minSlider.oninput = function(){
 outputMin.innerHTML=this.value;    
}

maxSlider.oninput = function(){
 outputMax.innerHTML=this.value;    
}
</script>

Demo

Video Tutorial

Watch our video tutorial on Price Range Slider With HTML CSS and JavaScript.

Neumorphic Search Bar Design with HTML and CSS Simple Login Form with Placeholder Animation Pure CSS Button with Folded Corner Background Color Change Slider with HTML CSS and JavaScript 404 Page Not Found Template Design with HTML and CSS Movies Blog Card Design with HTML and CSS Simple CSS Border Animation with before and after Selector Custom Social Select Dropdown Menu with CSS and JavaScript Facebook Offline and Online Notification with CSS and JS New Year 2022 Text Animation with CSS and JS Change Placeholder Color using CSS Custom Select Tag DropDown with CSS and JavaScript Profile Card With Hover Effect using HTML and CSS Simple Price Range Slider With HTML CSS and JavaScript Circle With Two Colors using CSS Card With Ribbon using HTML and CSS Simple Loading Screen using HTML and CSS Disable Textarea Resizable Property using CSS Button like Links using CSS Simple Dropdown Menu Using HTML and CSS Background Color Transition using CSS Highlight Required Input Fields using CSS Disable HTML Link using CSS Difference Between Descendant Selector and Child Selector How To Change Color and Size of Hr Tag Using CSS How To Center Align HTML Table Convert Checkbox To Toggle Button Using CSS Drawing Stars using HTML and CSS Button Bounce Effect using CSS Image as Text Background using CSS background-clip Property Vertically Rotate HTML Element using CSS Vertical Align Middle using CSS Text Over Image Hover Effect - Css Hover Simple CSS Button Hover Effect using Before Selector
Password Show Hide with Eye Icon using JavaScript Change Background Color using Dropdown menu with JavaScript Get Select Tag value onchange in JavaScript Check If Class Exists JavaScript Add Event Listener To all Elements of Class JavaScript getElementsByTagName Event Listener JavaScript Change type attribute of Input Element With JavaScript Password Hide and Show with Toggle Emoji Button using JavaScript Hide and Show Navbar On Scroll With JavaScript Empty an Array in JavaScript Get Last Element Of Array Without Removing It Remove Last Element From Array JavaScript Remove First Element From Array in JavaScript Tic Tac Toe Game in JavaScript Remove Class from HTML Tag OnClick JavaScript JavaScript Select li Tag By Index Display JavaScript Variable In HTML Insert HTML Code anywhere With JavaScript JavaScript Date Difference in Days JavaScript Hide Button After Click Simple Click and Hold Effect Using JavaScript Remove Class From All Elements in JavaScript JavaScript Select All HTML Elements Whose ID Start With Same String