Export (0) Print
Expand All

Pseudo-classes

Pseudo-classes are used to add special effects to a specific selector.

A pseudo-class is denoted by the use of a single colon, followed by the pseudo- class name.

Hyperlink pseudo-classes

A hyperlink can be styled using cascading style sheets to have a different appearance, according to its state. The four most commonly supported hyperlink pseudo-classes are listed in the following table:

:link

A hyperlink that has not been visited

:visited

A hyperlink that has already been visited

:hover

A hyperlink that the pointer is over

:active

A hyperlink that is currently selected

Cascading style sheet rules for hyperlink pseudo-classes will work correctly only when they appear in this order.

Other pseudo-classes

A hyperlink can be styled using cascading style sheets to have a different appearance, according to its state. The four most commonly supported hyperlink pseudo-classes are listed in the following table:

:active

Sets the style of an element when it is engaged or active.

:checked

Applies one or more styles to the form control element that is selected.

:disabled

Applies one or more styles to the form control element that is disabled.

:empty

Applies one or more styles to the element that has no child elements (including text nodes).

:enabled

Applies one or more styles to the form control element that is enabled.

:first-child

Applies one or more styles to any element that is the first child of its parent.

:first-of-type

Applies one or more styles to the element that is the first sibling element of its type.

:focus

Sets the style of an element when it gains focus.

:indeterminate

Applies one or more styles to radio buttons and check boxes whose toggle states cannot be determined—they are neither checked (selected) nor unchecked (cleared).

:lang

In a document, selects the elements that are in a given language.

:last-child

Applies one or more styles to the element that is the last child element of its parent element.

:last-of-type

Applies one or more styles to the element that is the last sibling element of its type.

:not

Applies one or more styles to elements that do not match a simple selector.

:nth-child

Applies one or more styles to the element that is the nth child of its parent element.

:nth-last-child

Applies one or more styles to the element that is the nth child of its parent element, counting from the last one.

:nth-last-of-type

Applies one or more styles to the element that is the nth sibling of its type, counting from the last one.

:nth-of-type

Applies one or more styles to the element that is the nth sibling of its type.

:only-child

Applies one or more styles to the element that is the last sibling element of its type.

:only-of-type

Applies one or more styles to the element that is the only sibling element of its type.

:root

Applies one or more styles to the element that is the root element of the document.

:target

Applies one or more styles to the target element of of the referring Uniform Resource Identifier (URI).

See also

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.

Community Additions

ADD
Show:
© 2015 Microsoft