[CSS Selector] E:target
'selector:target' applies styles to an element whose id matches the hash value in the URL. The 'hash value' (fragment, anchor) is the part of the URL after the '#' symbol. For example, in 'http://wp-p.info/index.html#hoge', 'hoge' is the hash value. This is commonly referred to as a 'pseudo-class' (the :target pseudo-class). It does not work in IE8 and below.
Sample Code
p:target { color: red;} /* Makes a p element with an id attribute matching the 'hash value' display in red. */
Browser Display Result
p:target { color: red;} /* Makes a p element with an id attribute matching the 'hash value' display in red. */
<a href="#hoge_sample">Click here to change the text color.</a> <p id="hoge_sample">The color will change.</p>
Click here to change the text color.
The color will change.
Browser Compatibility
Desktop
Supported in all versions
8 ×
7 ×
6 ×
8 and earlier ×Mobile
1 and earlier ×
Android Browser
2+ ○Same support as desktop
Same support as desktop
※ Version data is based on MDN.
If you find any errors or copyright issues, please contact us.