HTML and CSS Reference
In-Depth Information
The
:checked
and
:indeterminate
pseudo-
classes can only be applied to inputs of
type
checkbox
:
<label>Not checked
<input type="checkbox">
</label>
<label>Checked
<input type="checkbox" checked>
</label>
As you might expect,
:checked
lets you
style all checked check boxes:
input:checked {
outline: 4px solid #000;
}
You might use this to replace the default
check box with a graphic.
The indeterminate state has to be set by a
script:
input:indeterminate {
outline: 4px solid #000;
}
Note that
:indeterminate
is independent of
:checked
—both checked and unchecked
check boxes can be in the indeterminate state.
You can also use
CSS3
with the
HTML5
form features, such as validity. Here are
one valid and one invalid form field:
<label>Valid
<input type="url"
value="http://manning.com">
</label>
<label>Invalid
<input type="url"
value="Not a URL">
</label>