Role of CSS: valid Selector

Use the CSS : valid selector to style all <input> elements with a valid value .


You can try to run the following code to implement the :valid Selector

Live Demo

<!DOCTYPE html>
         input:valid {
            background: red;
            color: white;
      <input type = "email" value = "">
      <p>The style (red color background) appears if you type a relevant/ valid email address.</p>