0

I'm looking for a way to choose a parent if it has a decendent of class 'foo'. Is this possible using CSS..?

In the following example, I would want to choose parent (having class='B') as it has a descendent of 'foo'.

<parent class='A'>
    <child>
        <grand-child>
        <grand-child class='boo'>
    </child>
</parent>

<parent class='B'>
    <child>
        <grand-child>
        <grand-child class='foo'>
    </child>
</parent>
Emma
  • 226
  • 3
  • 9
  • Look at [this answer](https://stackoverflow.com/a/1014958/7874193) – Aleksa Ristic Oct 16 '21 at 03:04
  • Pretty sure the answer is "no". See https://css-tricks.com/parent-selectors-in-css/ and https://css-tricks.com/a-use-case-for-a-parent-selector/ – user2740650 Oct 16 '21 at 03:05
  • The general answer is no, but for some styling, such as changing background, or at least giving that visual appearance, it may be possible. What style you are trying to change? – A Haworth Oct 16 '21 at 04:42

0 Answers0