CSS :valid selector
Complete CSS Selector Reference Manual
Example
If the value entered in an input element is valid, set it to yellow:
input
:valid
{
background-color:
yellow
;
}
Try it »
Definition and usage
:valid selector sets a specified style when the value of a form element needs to be validated against specified conditions.
Note: The :valid selector only applies to elements that can specify a range of values, such as the min and max attributes of the input element, as well as a valid email field, a valid numeric field, and so on.
Browser support
The numbers in the table indicate the first browser version that supports this property.
| Selector | |||||
|---|---|---|---|---|---|
| :valid | 10.0 | 10.0 | 4.0 | 5.0 | 10.0 |
CSS Syntax
:valid
{
css 声明;
}
Related pages
CSS selector :invalid