0
<div class="container" >
    <p class="text_1">Text</p>
</div>
<div class="to_match" ></div>

How can you match the second div, as it is preceded with a parent with class "container", that has a child with the class "text_1".

I've attempted like this with no luck:

.container p.text_1 ~ .to_match{
     /*CSS*/
}
Zak Stucke
  • 423
  • 3
  • 16
  • to_match is sibling of the container not child of it? You want to access to_match? – Wahab Shah May 24 '20 at 12:28
  • @WahabShah apologies for typo, fixed now. I am trying to match the second div ("to_match"), when it has a sibling with the class "container" and that sibling has a child with the class "text_1" – Zak Stucke May 24 '20 at 12:30
  • you cannot do this with CSS, you are missing a parent selector – Temani Afif May 24 '20 at 12:31
  • @TemaniAfif what do you mean by "missing a parent selector"? ".container ~ .to_match" works fine, just combining it with the requirement the sibling's child has a class is the issue. – Zak Stucke May 24 '20 at 12:36
  • you need to (1) target container that contain an element with specific class THEN (2) select a siblign element. The first part need a parent selector which is no available in CSS (check the first duplicate) – Temani Afif May 24 '20 at 12:46

0 Answers0