Hello! This is my first post here on the CodeNewbie Forem and I'm kicking it off with a very beginner question. I'd love your thoughts!
Is there any way to select the parent of an element in CSS only?
Thanks 🙏
Hello! This is my first post here on the CodeNewbie Forem and I'm kicking it off with a very beginner question. I'd love your thoughts!
Is there any way to select the parent of an element in CSS only?
Thanks 🙏
For further actions, you may consider blocking this person and/or reporting abuse
LRMAPK -
Marcos Andrew -
alicecapsey -
JesicaW -
Top comments (4)
Currently there is no way of doing that with just CSS, unfortunately. There is a working draft for the ‘has()’ pseudo-class that does what you are looking for, but browser support is just not there. Read more about it here: developer.mozilla.org/en-US/docs/W...
In the meantime: what are you trying to achieve?
Thank you so much for this response! I'm trying to work with a menu via a CMS and I can't move the active element to
This is helpful, though :)
Like @murkrage said, you can't do it at the present.
If you need to style an element when one of his children is focused there is an handy pseudo-class you can actually use. It is supported in all major browser (maybe all)
You can read more about it here:
developer.mozilla.org/en-US/docs/W...
Thank you!!
Some comments may only be visible to logged-in visitors. Sign in to view all comments.