ProblemYou want to highlight the form field that a visitor is currently using. SolutionUse the :focus pseudo-class selector. With a preexisting form, create a new CSS rule that changes the background color when an input element is being used (see Figure 7-22). Figure 7-22. Background color of input field changes as text is enteredThis rule makes changes the background color of the field: input:focus { background-color: yellow; } DiscussionThe browsers that support :focus are Netscape Navigator 6+, Firefox, Safari, and Opera 7. Browsers that don't support the declaration block will simply ignore it, making it degrade gracefully. See AlsoRecipe 7.4, concerning styling for textarea elements; Table D-9 in Appendix D. |