← Back to pseudo-classes
CSS Pseudo-class / Element
:target
UI StateSelects the element whose ID matches the current URL fragment.
Syntax
#section:target { }Example
#section:target { background: #111; }Common use cases
- Highlighting a section when linked to via anchor
- Pure CSS tabs and accordions
- Animating a section into view on deep link
Practical developer insight
:target activates when the URL contains #element-id — you can build tab and accordion UIs entirely in CSS using :target combined with sibling selectors.