Style Input Elements with a Value Within a Specified Range using CSS



To style <input> elements with a value within a specified range, use the CSS :in-range selector. You can try to run the following code to implement the :in-range selector

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         input:in-range {
            border: 3px dashed orange;
            background: yellow;
         }
      </style>
   </head>
   <body>
      <input type = "number" min = "5" max = "10" value = "9">
      <p>The style only works for the value entered i.e. 9</p>
   </body>
</html>
Updated on: 2020-06-21T08:40:26+05:30

128 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements