CSS Selector Level 3 » Target pseudo-class

This pseudo-class is called target pseudo-class and represents an element which matches against fragment identifier of the URI. For example an URI is pointing to anchor named partHelp like here:

https://example.com/test.html#partHelp the element with the ID partHelp will be selected by this selector.

# Syntax

Copy
:target {
    /* declarations */
}

# Example

Copy
:target {
    outline: red dotted;
}

The element with the fragment identifier of the URI will have a red dotted outline border around itself.

Try example in CodePen

# Browser support

Platform Chrome Firefox Safari Edge Internet Explorer Opera
Desktop Yes (2.0) Yes (1.0) Yes (1.3) Yes (12.0) Yes (9.0) Yes (9.5)

Please wait a moment, the comments start loading now...
explorermozillachromesafariopera