Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS CSS selector for parent with blank element Reply To: CSS selector for parent with blank element

#262793
idan
Participant

https://css-tricks.com/parent-selectors-in-css/

a < img { border: none; }

“it would select <a> tags but only if they contained an <img> tag”
This one looks quite close to what I’m trying but wasn’t sure how to implement this method in my example
I tried the below but can’t get what I’m doing wrong:

li < p:empty {
  display: none;
}

In this example it Should select <li> tags but only if they contained an empty <p> tag; but it doesn’t, although it’s the exact same as the other example only with different tags

ps. this HTML needs to run within a javascript-disabled framework

Edit: Just realized this was only a suggested syntax rather than a working method
Is there any other HTML/CSS workaround to hide <li> elements with an empty <p> ? maybe with data selectors?