Pseudo-classes

Table of contents

  1. 1. Syntax
  2. 2. Examples
Table of contents
  1. 1. Syntax
  2. 2. Examples

« CSS « CSS Reference

A CSS pseudo-class is a keyword added to selectors that specifies a special state of the element to be selected. For example :hover will apply a style when the user hovers over the element specified by the selector.

Pseudo-classes, together with pseudo-elements, let you apply a style to an element not only in relation to the content of the document tree, but also in relation to external factors like the history of the navigator (:visited , for example), the status of its content (like :checked on some form elements), or the position of the mouse (like :hover which lets you know if the mouse is over an element or not).

Syntax

selector:pseudo-class {
  property: value;
} 

Examples

The following list is of some CSS3 level pseudo-class examples and may not have full browser support. Use fallback methods or JavaScript when necessary. To see a complete list of selectors, visit CSS3 Selectors working spec

Tags (3)

Edit tags

Attachments (0)

 

Attach file