We met pseudo elements in the last article. In this article we will discuss pseudo classes, which give you the ability to apply certain styling rules on specific states of an element. In this part we discuss the following pseudo classes: :link, :visited, :hover, :active and :focus, :root, :first-child, and :last-child. Note that with CSS 3 there are many new pseudo classes. Not all of them are implemented, however, so I will discuss only the pseudo classes that have been implemented by the major browsers.
Learn CSS: Pseudo Classes - The :active Pseudo Class (Page 4 of 5 )
The :active pseudo class applies the styling rules while the user is clicking on the element. It's supported by IE 5.5 and 6, Mozilla 1.7 and Opera 7.5. As with the :hover pseudo class, the :active class applies only to hyperlinks with IE, but in Mozilla it can be applied to any element. For this example, I will add a <p> element to the HTML code and two more CSS rules to the CSS code, which apply the hexadecimal background color #F6D5D5 and the text color #CC00CC to the active hyperlinks and the active paragraphs in the document. In the first following browser window the user is clicking on the first link; in the second window the user is clicking the paragraph. Add the following <p> element just before the closing tag of the <body> element:
<p>This is a paragraph text</p>
And add the following two CSS Rules to the CSS code file: