Question

Is it possible to target also another element like in the example ?

<a href="#AAA">click</a>
<div id="AAA">some content</div>
<div id="BBB">some content</div>

Something like...

#AAA:target #BBB{color:red}
Was it helpful?

Solution

In this case, you could use the adjacent sibling combinator, +.

EXAMPLE HERE

#AAA:target + #BBB {
    color:red
}

Depending on the markup, it might be better to use the general sibling combinator, ~. (example)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top