Home arrow Style Sheets arrow Page 4 - Learn CSS: Pseudo Classes

Learn CSS: Pseudo Classes

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.

Author Info:
By: Michael Youssef
Rating: 4 stars4 stars4 stars4 stars4 stars / 38
July 11, 2005
  1. · Learn CSS: Pseudo Classes
  2. · The :link and :visited Pseudo Classes
  3. · The :hover Pseudo Class
  4. · The :active Pseudo Class
  5. · The :focus Pseudo Class

print this article

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:

  background-color: #F6D5D5;
  color: #CC00CC;
  background-color: #F6D5D5;
  color: #CC00CC;

blog comments powered by Disqus

- CSS Padding Overview
- CSS: Margins Overview
- Top CSS3 Button Tutorials
- More Top CSS3 Tutorials for Animation and Im...
- CSS Mega Menus: Adding Extra Sections
- CSS Mega Menus
- CSS3 Accordian Menu: Horizontally Display Hy...
- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials