Invalid input Elements with :invalid
The :invalid selector matches input elements that are not valid based on input validation requirements.
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
<style>
:invalid {
outline: medium solid red;
}
:valid {
outline: medium solid green;
}
</style>
</head>
<body>
<form method="post" action="http://yourServer/form">
<p>
<label for="name">Name: <input required id="name" name="name"/></label>
</p>
<p>
<label for="name">City: <input required id="city" name="city"/></label>
</p>
<button type="submit">Submit</button>
</form>
</body>
</html>
Home
HTML CSS Book
CSS
HTML CSS Book
CSS
Pseudo Selectors:
- ::first-line Selector
- ::first-letter Selector
- :before Selector
- :after Selector
- CSS Counter Feature
- :root Selector
- Child Selectors
- :first-child Selector
- :last-child Selector
- :only-child Selector
- :only-of-type selector
- :nth-child(n)
- :nth-last-child(n)
- :nth-of-type(n)
- :nth-last-of-type(n)
- Enabled Elements with :enabled
- Disabled Elements with :disabled
- Checked Elements with :check
- Default Elements with :default
- Valid Elements with :valid
- Invalid input Elements with :invalid
- :in-range selector
- :out-of-range selector
- :required selector
- :optional selector
- :link selector matches hyperlinks.
- :visited selector matches visited hyperlinks.
- :hover Selector
- :active Selector
- :focus Selector
- Negation Selector not
- :empty Selector
- :lang Selector
- :target Selector
Related: