CSS - Pseudo-class :active


        Advertisements

        Description

        The :active pseudo-class is used to add special effect to an activated element.

        While defining pseudo-classes in a <style>...</style> block, following points should be taken care −

        • a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective.

        • a:active MUST come after a:hover in the CSS definition in order to be effective.

        • Pseudo-class names are not case-sensitive.

        • Pseudo-class are different from CSS classes but they can be combined.

        Possible Values

        • color − Any valid color value.

        Applies to

        Anchor / Link element.

        Example

        Following is the example which demonstrates how to use :active class to change the color of active links.

        <html>
           <head>
              <style type = "text/css">
                 a:active {color: #FF00CC}
              </style>
           </head>
        
           <body>
              <a href = "/html/index.htm">Click This Link</a>
           </body>
        </html> 
        

        This will produce following link. This will change its color to pink when user clicks it.

        css_references.htm
        Advertisements