How to CSS active element Selector :active

Description

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

Example


<!DOCTYPE HTML> 
<html> 
    <head> 
        <title>Example</title> 
        <style type="text/css"> 
        :active { <!--from ww w.  j a va2s.c  om-->
            border: thin black solid; 
            padding: 4px; 
        } 
        </style> 
    </head> 
    <body> 
        <a href="http://java2s.com">Visit the java2s.com</a> 
        <p>I like <span>HTML</span> and CSS.</p> 
        <button>Hello</button> 
    </body> 
</html>

Click to view the demo

The code above generates the following result.

:active




















Home »
  HTML CSS »
    HTML CSS Reference »




HTML Tag Reference
CSS Reference
CSS Selector Reference
Encoding Reference