« Previous Demo: Sticky Captions Concept Back to the Codrops Article

CSS Click Events :target way

The :target way

Clicking on the link below will change the URL by adding a hashtag to it. The element with the same ID will match the :target pseudo-class and become red.

Removing the hashtag in the URL, clicking another link or reloading the page are the only ways to restore the default state of the element.


Click me!

I’m going to be red! It’s gonna be legen... Wait for it...