Style <input> elements with a value outside a specified range with CSS



Use the CSS :out-of-range selector to style <input> elements with a value outside a specified range.

Example

You can try to run the following code to implement the :out-of-range selector:

Live Demo

<!DOCTYPE html> <html>    <head>       <style>          input:out-of-range {             border: 3px dashed orange;             background: yellow;          }       </style>    </head>    <body>       <input type = "number" min = "5" max = "10" value = "15">       <p>The style only works for the value entered out of range</p>    </body> </html>
Updated on: 2020-07-01T09:14:05+05:30

184 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements