: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:
#3
Contributed:
by fatihhayri
Date:
Tue, 03 May 2011 18:34:49 GMT
Status:
This note has not yet been confirmed for accuracy and relevance.

ie9 support

ID:
#2
Contributed:
by AlexDawson
Date:
Fri, 19 Feb 2010 23:58:12 GMT

Opera (up-to an including current versions) do not apply the rule when navigating the back and forward buttons.

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

IE8 is still not supporting the pseudo-class.

Related Products