CSS :target

Pseudo-classes :target

The :target pseudo-class represents an element that is the target element of the referring URI.

#section1:target {
  color: orange;
}
#section2:target { color: red; }
<a href='#section1'> Section 1 </a> | 
<a href='#section2'> Section 2 </a>

<section id='section1'>Section 1</section> <section id='section2'>Section 2</section>