-
Book Overview & Buying
-
Table Of Contents
Web Developer's Reference Guide
By :
These are pseudo-classes that can be used to target the state of input elements and more.
This attribute targets the checked radio button or checkbox:
:checked
Any element that can be toggled on or off can use this selector. As of now, these are radio buttons, checkboxes, and options in a selective list.
Here is an example with a checkbox and a label value:
<input type="checkbox" checked value="check-value" name="test" /> <label for="test">Check me out</label>
Here is a CSS rule that will target the label only when the checkbox is checked:
input:checked + label { color: #ff0000; }This targets the default element from many similar elements:
:default
Use this selector to help define the default element from a group of elements. In a form, this would be the default button or the initially selected option from a select element.
Here is an example using a form:
<form method="post">...
Change the font size
Change margin width
Change background colour