What I assume you’re asking is how do I target a parent container with CSS when a child container is clicked. If so its not possible, but the same selector is valid for the parent. For instance if you have an a tag inside of a div and you click on the a, you’ve also clicked on the div tag.
**Edit I say the same selector is valid. In some cases this is not true if the child was removed from the standard flow of the document through floats or absolute positioning and probably a few other fringe cases.
Here’s some pseudo code:
CSS
div.parent:active{
background:red;
}
a.child:hover{
color:blue;
}
HTML
<div class="parent">
<a class="child">Link</a>
</div>
solved When a button or checkbox is clicked, what css code do we use to select the container div?