Skip to: content, navigation

:target (CSS selector)

Spec
Version
CSS3
Browser support (more…)
IE8 FF1+ SA3.1+ OP9.5+ CH2+
None Full Full Full Full

Syntax

:target {
declaration block
}

Description

This pseudo-class matches an element that’s the target of a fragment identifier in the document’s URI. The fragment identifier in a URI comprises a # character followed by an identifier name that matches the value of an id attribute of an element within the document.

Example

For example, if the URI was http://www.example.com/index.html#section2, the following selector would match the element that had an id attribute of "section2":

:target {
  ⋮ declarations
}

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
None None None None Full Full Full Full Full Buggy Buggy Full Full None Full Full Full

In Safari versions up to and including 3, this rule isn’t applied when the user navigates using the back and forward buttons.

User-contributed notes

ID:
#1
Contributed:
by C.Ludwig
Date:
Thu, 16 Jul 2009 08:41:39 GMT

IE8 is still not supporting the pseudo-class.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

Search