CSS :target Pseudo-class
The :target
pseudo-class selects an element if it's the target of the current URL fragment. This allows you to style elements when they're linked to, creating interactive effects for single-page navigation or in-page anchors.
p:target {
background-color: violet;
}
<a href="#p1">Anchor</a></li>
<p id="p1">
This element will have a violet background when the user clicks on the anchor.
</p>