CSS :active Selector

Complete CSS ReferenceComplete CSS Reference

Example

How to style active links:

a:active
{
background-color:yellow;
}

Try it yourself »

Definition and Usage

The :active selector styles links to active pages.

A link becomes active when you click on it.

Tip: Use the :hover selector to style links when you mouse over them.

Note: :hover MUST come after :link and :visited (if they are specified) in the CSS definition in order to be effective!

Note: :active MUST come after :hover (if specified) in the CSS definition in order to be effective!


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The :active selector is supported in all major browsers.


CSS Version

The :active selector was first introduced in:

CSS 1


Related Pages

CSS tutorial: CSS Links

CSS tutorial: CSS Pseudo classes


Examples

Try it Yourself - Examples


Example

How to style a link, unvisited, visited, active, and when you mouse it:

a:link    {color:green;}
a:visited {color:green;}
a:hover   {color:red;}
a:active  {color:yellow;}

Try it yourself »

Example

How to give different links different styles:

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

Try it yourself »

Complete CSS Reference Complete CSS Reference