151 of 313 menu

The hover pseudo-class

The hover pseudo-class sets styles for the link we hover over. Typically, this pseudo-class is used in conjunction with link, visited and active pseudo-classes.

Syntax

a:hover { }

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 active,
    which sets the style of the link in activation
  • pseudo-class focus,
    which sets the style of the link in focus
byenru