Pseudo Classes

Category:CSS Properties

Pseudo Classes

The pseudo-classes property is used to add special effects to some selectors. This property can be used mainly to: Style an element when a user mouses over it. Style visited and unvisited links differently.

Examples

Unvisited Link

Using the :link pseudo-class on a link <a> element to change color.

a:link {
  color: blue;
}

Visited Link

Using the :visited link pseudo-class on a link<a> element to change color.

a:visited link {
  color: green;
}

Mouse Over Link

Using the :hover pseudo-class on a link<a> element to change color.

a:hover {
  color: green;
}

Syntax

selector:pseudo-class {
  property: value;
}

Tips

  • Pseudo-class are different from CSS classes but they can be combined.
  • Pseudo-classes help you cut down on excess classes in your markup.

Additional Information

For more information, see http://www.w3schools.com/Css/css_pseudo_classes.asp

Found a bug in the documentation? Let us know at documentation@code.org