Pseudo-Class Selectors
Pseudo-class selectors match elements according to a condition not involving their name. There are seven of these separated from the element name by a colon.
first-childThis pseudo-class matches the first child element of the named element. When applied to Example 13-1, this rule italicizes the first, and only the first,
stepelement:step:first-child {font-style: italic}linkThis pseudo-class matches the named element if and only if that element is the source of an as yet unvisited link. For example, this rule makes all links in the document blue and underlined:
*:link {color: blue; text-decoration: underline}visitedThis pseudo-class applies to all visited links of the specified type. For example, this rule marks all visited links as purple and underlined:
*:visited {color: purple; text-decoration: underline}activeThis pseudo-class applies to all elements that the user is currently activating (for example, by clicking the mouse on). Exactly what it means to activate an element depends on the context, and indeed not all applications can activate elements. For example, this rule marks all active elements as red:
*:active {color: red}- linking
These pseudo-classes are not yet well-supported for XML documents because most browsers don’t recognize XLinks. So far, only Mozilla and Netscape 6/7 recognize XLinks, and they are the only browsers that will apply these pseudo-classes to XML.
hoverThis pseudo-class applies to elements on which the cursor is currently positioned ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access