CSS3 :target Selector


Example

Highlight active HTML anchor:

:target {
    border: 2px solid #D4D4D4;
    background-color: #e5eecc;
}

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.

Version: CSS3

Browser Support

The numbers in the table specifies the first browser version that fully supports the selector.

Selector
:target 4.0 9.0 3.5 3.2 9.6

CSS Syntax

:target {
    css declarations;
}



SHARE THIS PAGE

COLOR PICKER

colorpicker





Search w3schools.com:

Translate w3schools.com: