HTML and CSS Reference
In-Depth Information
In this example, the styles-conscious browser renders unvisited links in
blue. When the user selects a link, the browser changes its color to red
and makes it bold. Once visited, the link reverts to green.
8.3.4.2. Interaction pseudoclasses
The CSS2 standard defines two new pseudoclasses that, along with
:active , relate to user actions and advise the interactive agent, such
as a browser, how to display the affected element as the user interacts
with the element. In other words, these two pseudoclasses hover and fo-
cus are dynamic.
For instance, when you drag the mouse over a hyperlink in your doc-
ument, the browser may change the mouse-pointer icon. Hovering can
be associated with a style that appears only while the mouse is over the
element. For example, if you add the :hover pseudoclass to our example
list of hyperlink style rules:
a:hover {color: yellow}
the text associated with unvisited links normally appears blue, but turns
yellow when you point to it with the mouse, red after you click the link
and while you are visiting it, and green after you're done visiting the
hyperlink.
Similarly, the :focus pseudoclass lets you change the style for an ele-
ment when it becomes the object of attention. An element may be under
focus when you tab to it, click on it, or, depending on the browser, ad-
vance the cursor to it. Regardless of how the focus got to the element,
the style rules associated with the focus pseudoclass are applied only
while the element has the focus.
 
Search WWH ::




Custom Search