This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

:active

Summary

The :active pseudo-class applies while an element is being activated by the user.

The :active pseudo-class applies while an element is being activated by the user. For example, between the times the user presses the mouse button and releases it. On systems with more than one mouse button, :active applies only to the primary or primary activation button (typically the “left” mouse button), and any aliases thereof.

Examples

The following style rule uses the :active pseudo-class to set the font-weight and color attributes of an active link in a document.

a:active { font-weight:bold; color:purple }

Usage

 The :active pseudo-class is most often used with the a element.

The :active pseudo-class is often used with :hover, :link, and :visited, the pseudo-classes that affect the other states of a link.

Notes

It is undefined if the parent of an element that is ‘:active’ or ‘:hover’ is also in that state.

The default value of the :active pseudo-class is browser-specific.

By default, Safari Mobile does not use the :active state unless there is a touchstart event handler on the relevant element or on the body.

Related specifications

CSS 2.1
W3C Recommendation
Selectors Level 3
W3C Recommendation
Selectors Level 4
W3C Working Draft

Attributions