CSS3 :target Selector

Example

Add an image in front of the current active HTML anchor:

:target:before
{
content: url(../assets/lamp.gif);
}

Try it yourself »

Definition and Usage

URLs with an # followed by an anchor name, link to a certain element within a document. The element being linked to is the target element.

The :target selector can be used to style the current active target element.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The :target selector is supported in all major browsers, except Internet Explorer.