First page Back Continue Last page Graphics
Pseudo-elements and Pseudo-classes
Two special predefined groupings, called pseudo-elements and pseudo-classes, are used in CSS to deal with special situations that do not exist with standard HTML. For example, under standard HTML, there is no way to automatically change the look and feel of the first letter or line of a paragraph. But by using the pseudo-element :first-letter you can specify a style that affects it:
- p:first-letter { font-size: 200%; color:red;}
Under standard HTML, there is no mechanism to deal with mouse movements. But with CSS, the pseudo-class :hover can be used to change the style of a link. In this example, a:hover is used to change the link color to red and the underlining to disappear whenever a mouse hovers over links:
a:hover {color: #ff0000; text-decoration: none;)
To change the style of links, use the pseudo-class :link
To change the style of visited links, use the pseudo-class :visited
- a:link {color: #00f; font-weight: bold;)
- a:visited {color: purple; border: groove;}