HTML and CSS Reference
In-Depth Information
___________
2 Applies after user has clicked into the text field.
3 Input will be invalid until a valid email address is entered.
The :focus selector isn't just for forms, but its behavior is easiest to see in the con-
text of web forms. Applied to text fields, the :focus selector adds a style when the
user clicks in the field and begins to type. When the user clicks another field, the focus
moves, and the style rule is applied accordingly. Taking the web form that appeared in
Chapter 4 , we could add this simple style:
input:focus {
border:5px solid black;
}
This style rule will add a prominent black border around any text field the user clicks
in to start typing. It will make it clear which text field currently has focus ( Figure 6-5 ).
Search WWH ::




Custom Search