CSS :out-of-range Pseudo Class

The :out-of-range pseudo-class styles the elements that have range limitations when the value of the element is outside the specified range.

The :out-of-range selector only works for <input> elements with min and/or max attributes.

Version

Selectors Level 4

Syntax

:out-of-range {
  css declarations;
}

Example of the :out-of-range selector:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      input:out-of-range {
        border: 3px solid #8ebf42;
      }
    </style>
  </head>
  <body>
    <h2>:out-of-range selector example</h2>
    <form>
      <input type="number" min="1" max="12" value="15">
    </form>
  </body>
</html>

Browser support

chrome edge firefox safari opera
10.0+ 29.0+ 11.0+

Practice Your Knowledge

What is the purpose of the :out-of-range pseudo-class selector in CSS?

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?