Skip to content Skip to sidebar Skip to footer

Set The Active Link Styles When Using A Hash Or Url Fragment?

Doesn't the active link show the styles of the current page? I'm trying to apply a style on the active page but it's not working. I'm using a url hash or url fragment. When using

Solution 1:

You can use the :target pseudo-class:

:target {
   cursor: pointer;
   border-bottom: 2px solid #FF0000;
}

The :target CSS pseudo-class represents a unique element (the target element) with an id matching the URL's fragment.

Post a Comment for "Set The Active Link Styles When Using A Hash Or Url Fragment?"