0

Is there any way or CSS selector where we can target the parent div?

For exp:

<div class="xylem"> 
  <div class="xyz2 show"></div>
</div>

When show class comes then I want to target (XYLEM parent class) in there any way guys?

Bashir
  • 2,057
  • 5
  • 19
  • 44
  • For exp: When show class comes i want to target xylem class. – nitin karwal Dec 22 '20 at 06:21
  • No, you can't select parent by its children, for now. Maybe in the future we can use [`:has`](https://developer.mozilla.org/en-US/docs/Web/CSS/:has) selector, you can see the [browser compatibility](https://caniuse.com/?search=%3Ahas) here. – Hao Wu Dec 22 '20 at 06:26
  • @HaoWu is correct in saying that there is no parent selector as such. However, sometimes it is possible to achieve an effect that is desired, for example by introducing a pseudo element on the child which makes it look as though the background to the parent has been altered. If you describe exactly what you want to achieve, with relevant HTML and CSS we could take a look - but the possibilities are limited. – A Haworth Dec 22 '20 at 06:40
  • 2
    Does this answer your question? [Is there a CSS parent selector?](https://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector) – Mohammad Javad Noori Dec 22 '20 at 06:44

0 Answers0