user3439263
user3439263

Reputation:

CSS :target another element

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}

Upvotes: 1

Views: 1311

Answers (1)

Josh Crozier
Josh Crozier

Reputation: 240868

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)

Upvotes: 2

Related Questions