Use the :active CSS pseudo-class to style an element when the user presses down the left or primary mouse button.


<element>:active {css-style}

Example 1

Changing the color of a link on mouse down:

a:active {color: red;}


Click the following link and you will notice that on mouse down it will turn red. Test me

Example 2

Change the background color of a paragraph on click:

p:active {background-color: #eee;}


Click on this paragraph and on mouse down its background color will change to light gray.
This is another line.


CSS – :active

Related Tutorials

Vinish Kapoor

An Oracle Apex Consultant, Oracle ACE, and founder of and a question and answer forum for developers.

Leave a Reply