Skip to: content, navigation

:target (CSS selector)

Spec
Version
CSS3
Browser support (more…)
IE7 FF1+ Saf1.3+ Op9.5+
None Full Buggy 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
5.5 6.0 7.0 1.0 1.5 2.0 1.3 2.0 3.0 9.2 9.5
None None None Full Full Full Buggy Buggy Buggy None 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

There are no comments yet.

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