English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS reference manual

CSS @rules

CSS attribute大全

CSS :active Selector

Complete CSS Selector Reference Manual

Online Example

Sets the style of active link:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title> 
<style> 
a:active
{
background-color:lightgreen;
}
</style>
</head>
<body>
<a href="//www.oldtoolbag.com">oldtoolbag.com</a>
<a href="//www.pcjson.com" target="_top">pcjson.com</a>
<p><b>Attention:</b>  :active selector style triggers when linking to the link page</p>
</body>
</html>
Test and see ‹/›

Definition and Usage

:active adds special styles to active links.

When you click on a link, it becomes an active link.

Hint:  :link Selector sets the style of unvisited page links. :visited Selector sets the style of visited page links. :hover Selector for link styles when the mouse hovers over them.

Note: To produce the expected effect, in the CSS definition, :active must come after :hover!!

Browser Compatibility

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

Selector




:active4.07.02.03.19.6

Note:for all elements in IE8and all new versions of browsers support the :active selector. The :active selector is for IE7Supports links only.

Related Articles

CSS Tutorial: CSS Links

CSS tutorial: CSS Pseudo-classes

Online Example

Active, visited, unvisited, or when the mouse hovers over the link:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title> 
<style>
a:link {color:green;}
a:visited {color:green;}
a:hover {color:red;}
a:active {color:yellow;}
</style>
</head>
<body>
<p>Move the mouse over and click this link: <a href="//www.oldtoolbag.com/">oldtoolbag.com</a></p>
</body>
</html>
Test and see ‹/›

Online Example

Different link styles:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title> 
<style>
a.ex1:hover,a.ex1:active {color:red;}
a.ex2:hover,a.ex2:active {font-size:150%;}
a.ex3:hover,a.ex3:active {background:red;}
a.ex4:hover,a.ex4:active {font-family:monospace;}
a.ex5:visited,a.ex5:link {text-decoration:none;}
a.ex5:hover,a.ex5:active {text-decoration:underline;}
</style>
</head>
<body>
<p>Move the mouse over the link to see the style change./p>
<p><a class="ex1" href="/css/">This link changes the color</a></p>
<p><a class="ex2" href="/css/">This link changes the font size</a></p>
<p><a class="ex3" href="/css/">This link changes the background color</a></p>
<p><a class="ex4" href="/css/">This link changes the font type</a></p>
<p><a class="ex5" href="/css/">This link changes the text decoration</a></p>
</body>
</html>
Test and see ‹/›

Complete CSS Selector Reference Manual