HTML and CSS Reference
In-Depth Information
The pseudo-class for valid inputs is,
unsurprisingly, :valid :
input:valid {
outline: 4px solid #000;
}
And the corresponding pseudo-class is
invalid :
input:invalid {
outline: 4px solid #000;
}
It's also possible to style required inputs.
Here are one required and one optional
input (of course, inputs are optional by
default):
<label>Required
<input type="text" required>
</label>
<label>Optional
<input type="text">
</label>
This is the CSS to select an input with the
required attribute:
input:required {
outline: 4px solid #000;
}
And this is the CSS to target just the
optional input:
input:optional {
outline: 4px solid #000;
}
Search WWH ::




Custom Search