Skip to content
Related Articles

Related Articles

Improve Article

CSS | : valid Selector

  • Last Updated : 04 Dec, 2018

The :valid selector is used to select the form elements with a given value that validates according to the elements.

This selector only works for form elements with some limitations such as input elements with min and max attributes, email fields with a legal email, or number fields with a numeric value, etc.


:valid {
    // CSS property


<!DOCTYPE html>
        <title>valid selector</title>
            h1 {
            input:valid {
                background-color: green;
            body {
        <h2>:valid Selector</h2>
        Email Address: <input type="email" placeholder="">


Supported Browsers: The browser supported by :valid selector are listed below:

  • Apple Safari 5.0
  • Google Chrome 10.0
  • Firefox 4.0
  • Opera 10.0
  • Internet Explorer 10.0

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :