The :invalid CSS pseudo-class represents any <input> or <form> element whose content fails to validate according to the input's type setting. This allows you to easily have invalid fields adopt an appearance that helps the user identify and correct errors.

:invalid {
    css declarations;
}
input:invalid {
   color: #3366ff;
   background: red;
}

Click the button below to experiment with this selector.

Give it a Try!

4.0Firefox 10.0Explorer 10.0Chrome 5.0Safari 10.0Opera