CSS :validSelectors


Complete CSS Selector Reference Manual

Example

If the value entered in the input element is valid, set it to yellow:

input:valid { background-color: yellow; }

Try it Yourself »

Definition and use

The :valid selector sets specified styles when a form element's value needs to be validated according to specified conditions.

Note:The :valid selector only applies to elements that can specify a range of values, such as the min and max attributes in input elements, correct email fields, valid number fields, etc.


Browser Support

The numbers in the table indicate the first browser version number that supports the property.

Selectors
:valid 10.0 10.0 4.0 5.0 10.0

CSS Syntax

:valid
{
    css 声明;
}


Related Pages

CSS Selector:invalid


Complete CSS Selector Reference Manual

other extensions