Cascading Style Sheets/Hyperlinks

The  selector matches hyperlinks. There are the four pseudo-classes that are commonly used with it:,  ,   and. Rules using these pseudo-classes should be given in this order so that the dynamic effects take precedence over the visited/unvisited state. The following example will display a link that is black, changes to green when the mouse is over it, and changes to pink when active (whilst the mouse is pressed over it).

When the mouse is over an unvisited link both the  selector and the   selector are matched. Since the hover rule appears last its  declaration takes precedence over the link rule's   declaration. Since the hover rule does not alter the  property the result is green text on a gray background.

The  and   pseudo-classes can only be used with the   selector. CSS2.1 allows the  and   pseudo-classes to be used with other elements. However, Internet Explorer only allows  on anchor elements.