HTML and CSS Reference
In-Depth Information
figure 6-72
Pseudo-classes for web form controls
Check boxes or options that are checked
The default user control element
Control elements that are disabled
Control elements that are enabled
Control elements that have the focus (are actively selected) in the form
Check boxes or option buttons whose toggle states (checked or unchecked)
cannot be determined
Control elements whose values are within each field's range of values (between
the min and max attribute values)
Control elements whose values fail validation tests
Control elements that are optional (not required) in the Web form
Control elements whose values are outside each field's range of values (outside
of the min and max attribute values)
Control elements that are required in the Web form
Control elements whose values pass validation tests
For example, to create styles for all of the option buttons in a form that are checked,
you could apply the checked pseudo-class, as in the style rule
input[type=”radio”]:checked {
where styles is the CSS styles applied to checked option buttons.
The first pseudo-class you'll apply to the survey form will be used to change the back-
ground color of any element that has the focus. focus refers to the state in which an ele-
ment has been clicked by the user, making it the active control element on the form. You
may have noticed that some browsers highlight or add a glowing border around control
elements that have the focus. Alice would like the control elements that have the focus to
be displayed with a light green background color.
To apply the focus pseudo-class:
1. Return to the forms.css file in your text editor.
2. At the bottom of the file, insert the following style rule, as displayed in
Figure 6-73:
/* Validation styles */
input:focus, select:focus, textarea:focus {
background-color: rgb(220, 255, 220);
Search WWH ::

Custom Search