Change either value to flip between the two states.
How It Works
Share the same min/max. Both fields use 1–10.
Style good values.:in-range adds a light green fill.
Style bad values.:out-of-range adds red fill and border.
Let the browser decide. As the user edits, the matching pseudo-class updates.
Edge Cases & Pitfalls
Most surprises come from missing limits or empty values.
limits
No min/max → no match
Without a range limitation, :out-of-range never applies. Add min and/or max first.
empty
Empty is not always out of range
An empty optional field may be neither in-range nor out-of-range. Use :invalid / :required for emptiness rules.
vs invalid
Narrower than :invalid
Out-of-range values are often also invalid, but :invalid covers more cases (pattern, required, type mismatch).
types
Wrong input type
type="text" with min/max does not create a numeric range for this pseudo-class. Use number, date, and similar.
a11y
Color alone is not enough
Pair the style with a clear label or message so the error is understandable without relying only on red/orange.
Compatibility
Browser Support
:out-of-range is a browser CSS pseudo-class. Node.js, Deno, and Bun do not evaluate it.
✓ Baseline · Widely available
:out-of-range
Supported across modern browsers (Baseline Widely available since about November 2015). Safe for progressive form feedback.
98%All modern browsers
Google ChromeAll
Full
Mozilla FirefoxAll
Full
Apple SafariAll
Full
Microsoft EdgeAll
Full
OperaAll
Full
Samsung InternetAll
Full
Internet Explorer10+
Partial
input:out-of-rangeWidely supported
Bottom line: Production-ready for modern browsers. Keep server-side validation as the source of truth.
Remember
Key Takeaways
Role: style inputs whose value is outside min/max.
Needs: a range-capable input plus min and/or max.
Pair: use :in-range for allowed values.
Tip: CSS feedback helps UX; server validation stays required.
One line::out-of-range styles a value that breaks the input’s min/max limits.
Frequently Asked Questions
It matches an <input> whose current value is outside the limits set by its min and/or max attributes.
Controls that support range limits—typically type="number", "range", "date", "time", "datetime-local", "month", and similar—when min and/or max are set.
Then the control is neither :in-range nor :out-of-range. The pseudo-class only applies when a range limitation exists.
:out-of-range only checks min/max. :invalid also covers required emptiness, pattern failures, and other constraint validation errors.