Selecting Link Elements Based on Their State

CSS lets you apply formatting to links based on their current state, that is whether they’ve been visited, whether the visitor is hovering their cursor on top of them, or whatever.

Figure 9.28. You can’t specify in the code what state a link will have. It’s controlled by your visitors.

To select link elements to format based on their state:

1.
Type a (since a is the name of the link tag).
Figure 9.29. Styles for links should always be defined in this order, to avoid overriding properties when a link is in more than one state (say, visited and hovered).

2.
Type : (the colon).
Figure 9.30. Links ...

Get HTML, XHTML, & CSS, Sixth Edition: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.