:valid

Targets any form element that currently meets its requirements (like matching a 'pattern' or having content in a 'required' field). Unlike ':user-valid', this can match immediately on page load.

Quick example

input:valid {
  background-color: #f0fff0;
  /* highlights valid fields immediately */
}

:valid Browser Support

Widely available Since 2015 96% global usage

This feature is well established and works across many devices and browser versions. It has been available across browsers since 2015.

Safe to use without fallbacks.

10+
4+
5+
12+
ESC