The target container pseudo-class acts like :target
by matching elements whose descendant in the flat tree matches the target as well.
# Syntax
Copy
:target-within {
/* declarations */
}
# Example
Copy
article:target-within {
background-color: #cccccc;
}
After clicking on the anchor jump link the article with its nested anchor element matching the target will get a grey background.
Try example in CodePen# Browser support
Platform
Chrome
Firefox
Safari
Edge
Internet Explorer
Opera
Desktop
No
No
No
No
No
No
Mobile
No
No
No
No
No
No
For future browser support information, also check out caniuse.com (Target container pseudo-class).
# Usage statistics (Alexa Top 1,250,000 sites)
Due to an extreme price increase of our statistics provider the data collection was stopped in September 2018.
Please wait a moment, the comments start loading now...