CSS Selector - How to CSS active element Selector :active

The :active selector matches activating elements. The :active selector isn't limited to elements with which the user can interact.

:active is a Pseudo-class selector and it applies to an element that is being activated.

The most common example is clicking on a hyperlink in an HTML document: while the mouse button is being held down, the link is active.


a:active  {color: red;}
*:active {background: blue;}


CSS Version

CSS Syntax

:active { 
   style properties 

Browser compatibility

:active Yes 7.0 Yes Yes Yes


An example showing how to use :active CSS selector.

        <style type="text/css"> 
        :active { <!--from  w  w  w.  ja v  a 2  s.c  o m-->
            border: thin black solid; 
            padding: 4px; 
        <a href="http://java2s.com">Visit the java2s.com</a> 
        <p>I like <span>HTML</span> and CSS.</p> 

Click to view the demo