-2

let's consider an example

 .parent-class{
    width: 20px;
  }
 .child-class{
    width: 5px;
  }

I just want to apply the height: 10px style to .parent-class by using .child-class name. let's consider HTML code just like below

<div class="parent-class">
  parent
   <div class="some-other-class">
       internal
       <div class="child-class">
       child
       </div>
   </div>
</div>

I don't want to use the .parent-class name while applying height: 10px style to it

I appreciate your help, Thanks!

Exception
  • 571
  • 1
  • 3
  • 15

1 Answers1

0

There is this :has() selector for that.

.parent-class:has(.child-class){height: 10px;}

Cheers

TomPich
  • 11
  • 2