Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS :active selector

CSS :active selector

Complete CSS SelectorComplete CSS Selector Reference Manual

Example

Select the style of an active link:

a:active

{

background-color:yellow;

}

Try it »


Definition and Usage

:active adds a special style to an active link.

A link becomes active when you click it.

Tip: :link The selector sets the style of unvisited page links, :visited The selector sets the style of visited page links, :hover The selector styles links when the mouse hovers over them.

Note: For the effect to appear as expected, in the CSS definition :active must come after :hover!!


Browser support

The numbers in the table indicate the first browser version that supports this property.

Selector
:active 4.0 7.0 2.0 3.1 9.6

**Note:** In IE8 and newer browsers the :active selector is supported for all elements. In IE7 the :active selector only supports links.


Related Articles

CSS Tutorial: CSS Links

CSS tutorial: CSS pseudo-classes


More examples

Example

Active, visited, unvisited, or links with the mouse hovering over them:

a:link    {color:green;}

a:visited {color:green;}

a:hover   {color:red;}

a:active  {color:yellow;}

Try it »

Example

Links with different styles:

a.ex1:hover,a.ex1:active {color:red;}

a.ex2:hover,a.ex2:active {font-size:150%;}

Try it »


Complete CSS SelectorComplete CSS Selector Reference Manual