I have a structure of div
s inside div
s, something like:
<div>
<div>
<div class='a'>Hello</div>
<div class='a'>Stack</div>
<div>Overflow</div>
</div>
<div>
<div>You</div>
<div class='b'>Are</div>
<div class='b'>The Best</div>
</div>
<div>
<div>Have</div>
<div class='b'>a nice</div>
<div>Day !!</div>
</div>
</div>
I would like all div
s with class a
to change the background color when one of them is hovered by mouse. The same for all div
s with class b
: when one of div
s with class b
is hovered, all div
s with class b
should change the background color.
Is that possible to implement this behavior without Javascript ?
If the answer is no:
Is that possible if known that all div
s with class a
are consecutive div
s in the same level (i.e. siblings) ?
I can add also other classes to div
s, if needed.