XML technologies / CSS / CSS Cookbook / General information / Different selectors for assigning styles / Pseudo-classes

(Excerpt from “CSS Kochbuch” by Christopher Schmitt)

Sometimes you want to style elements selected on a basis other than their names, attributes or content. This example uses pseudo-classes to create rollover effects:

a:link {
 color: blue;
}
a:visited {
 color: purple;
}
a:hover {
 color: red;
}
a:active {
 color: gray;
}

In this example, a link normally appears in blue. When the pointer moves over it, it turns red. While it is being clicked, it appears grey. Returning to the page after visiting the link displays it in purple.

Three further pseudo-classes are :first-child, :focus and :lang(n).

  

 

 

 

back to top