:valid - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:valid

Description

The :valid selector selects valid form elements.

The valid form elements includes as input elements with min and max attributes, email fields with a legal email, or number fields with a numeric value, etc.

Example

Select only if the value of the <input> element is valid:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
input:valid {<!--from w  ww.  j av a 2s . com-->
    background-color: yellow;
}
</style>
</head>
<body>

<input type="email" value="support@a.com">

<input type="email" value="support.com">

</body>
</html>

Related Tutorials