Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS :invalid selector

CSS :invalid selector

Complete CSS Selector Reference Manual Complete CSS Selector Reference Manual

Example

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

input

:invalid

{

border:

2

px

solid

red

;

}

Try it »


Definition and usage

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

Note: :invalid 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 valid email fields, valid numeric fields, and so on.


Browser support

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

Selector
:invalid 10.0 10.0 4.0 5.0 10.0

CSS Syntax

:invalid

{

css declaration

;

}


Related pages

CSS selector :valid


Complete CSS Selector Reference Manual Complete CSS Selector Reference Manual