0

This is the code, I've tried different attribute selectors with no avail. It important that the element is inside a div since it simulates the structure in the real website.

#AAA:checked ~ #BBB {
    color:red;
}


<div>
<input type="radio" id="#AAA">click
</div>


<div id="CCC">some content</div>
<div id="BBB">some content</div>

Fiddle where I've been experimenting

Ricardo DM
  • 33
  • 5
  • While the input is inside the div you have it in it can't affect elements outside it with CSS. Selectors work for descendants & siblings. Not up then down the DOM. – Paulie_D Jul 13 '18 at 12:09
  • There's no parent selector in CSS, therefore it's impossible to style the sibling of a parent element based on the style of that parent's child. In this case styling `#CCC` and `#BBB` based on the `:checked` state of the `` is impossible without JavaScript. – David Thomas Jul 13 '18 at 12:09
  • You are probably better off using some Javascript to do this. – Nisarg Shah Jul 13 '18 at 12:10

0 Answers0