asp.net.ph

Skip Navigation Links

active Pseudo-class

CSS Attributes Index   Pseudo-class Attributes


Sets or retrieves the style of the active hypertext link ( anchor element ) in a document.

Syntax


CSS [ A ] :active { attribute1:parameter1 [ ; attribute2:parameter2 [ ; . . . ] ] }
Script N/A

Possible Values


attribute Any attribute applicable to text.
parameter Any of the range of values available to the corresponding attribute.

This pseudo-class is read/write with a default value that is browser-specific.

Remarks

Active means that the user is currently navigating the link. Setting the active pseudo-class is often used in conjunction with the following pseudo-elements to define the various states of a link: link, visited, and hover.

Using pseudo-classes on elements other than the A element has no effect.

Example

The following demonstrates use of the a:active attribute in an embedded stylesheet to set the color of the current active hyperlink on a page. When used in an external stylesheet which is linked to all pages of a site, this same declaration will apply the style to the current active link in any page of the site. The below styles are actually what are used on this site for hyperlinks.

<style type="text/css">
<!--
   a:link, a:visited {
      color: #005 }
   a:active {
      background-color: #eec; color: #500 }
   a:hover {
      color: #500 }
-->
</style>

The CSS :active attribute can also be used for contextual hyperlinks, or links which are contained within other selectors. For instance:

ul a:link, ul a:visited, ul a:active {
   font: bold 11pt Arial; color: #9cf;
   text-decoration: none }
.showme a:link, .showme a:visited, .showme a:active {
   font: bold 11pt arial; background: navy; color: lime;
   text-decoration: none; padding: 3 }
.showme a:hover {
   background: maroon; color: yellow;
   text-transform: uppercase }

That declaration will apply the style to all links within an unordered list ( UL ) element, as well as to elements whose class attribute is set to showme.

Applies To

A

See Also

hover, link, visited



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note