152 of 313 menu

The active pseudo-class

The active pseudo-class sets styles for a link at the moment it is clicked (we pressed and did not release the button - as long as we do not release it, the specified styles work).

Typically, this pseudo-class is used in conjunction with the link, hover and active pseudo-classes.

Syntax

a:active { }

Example

An unvisited link will be red, a visited link will be blue. If you hover over it with the mouse, it will turn green, and if you press the left mouse button and hold it, it will turn black (active state):

<a href="#">link</a> a:link { color: red; } a:visited { color: blue; } a:hover { color: green; } a:active { color: black; }

:

See also

  • pseudo-class link,
    which sets the style for an unvisited link
  • pseudo-class visited,
    which sets the style for a visited link
  • pseudo-class hover,
    which sets the style for a hover link
  • pseudo-class focus,
    which sets the style of the link in focus
byenru