CSS :invalidSelectors

Complete CSS Selector Reference Manual

Example

If the value in the input element is invalid, set the style to red:

input:invalid { border:2px solid red; }

Try it Yourself »

Definition and use

The :invalid selector is used to set specified styles when the value in a form element is invalid.

Note:The :invalid selector only works on elements that can specify range values, such as the min and max attributes in input elements, as well as 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
:invalid 10.0 10.0 4.0 5.0 10.0

CSS Syntax

:invalid
{
CSS Declaration;
}


Related Pages

CSS Selectors:valid


Complete CSS Selector Reference Manual

other extensions