Easy Tutorial
❮ Pr Border Left Color Css3 Pr Animation Keyframes ❯

CSS :valid Selector


Complete CSS Selectors Reference

Example

Set the input element to yellow if the entered value is valid:

input:valid {
    background-color: yellow;
}

Definition and Usage

The :valid selector is used to set a specific style for form elements whose values need to be validated based on specified conditions.

Note: The :valid selector only works on elements that can specify range values, such as the min and max attributes in input elements, correct email fields, valid numeric fields, etc.


Browser Support

The numbers in the table represent the first browser version that supports this property.

Selector
:valid 10.0 10.0 4.0 5.0 10.0

CSS Syntax

:valid {
    css declarations;
}

Related Pages

CSS Selector :invalid


Complete CSS Selectors Reference

❮ Pr Border Left Color Css3 Pr Animation Keyframes ❯