Search code examples
htmlcssstylesstylesheetstylus

Id a div has a grandchild with a specific class


Is there any way to apply css to a specific div if it only has a grandchild with a specific class; lets say:

1)

<div class="grand-parent">
  <div>
    <div class="grand-child">
    </div>
  </div>
</div>

2)

<div class="grand-parent">
  <div>
    <div>
    </div>
  </div>
</div>

In my example I want to apply css to grandparent which has grandchild div with class grand-child which is true in my example 1 and not example 2.


Solution

  • Unfortunately there is now way in CSS that a children can affect a parent.