on click css

CSS
:active {
  css declarations;
}
    a:active
 {   
 background-color: yellow;
 }P Example
Click on a <p> element to change its text color to red:

 <p id="demo" onclick="myFunction()">Click me to change my text color.</p>

 
<script>
function myFunction() {
    document.getElementById("demo").style.color = "red";
}
</script>
 
Source

Also in CSS: