Is it possible to hide a parent element, if its child is empty? I know there is the :empty selector, but it only works, if the parent doesn't contain anything, including HTML elements.
This is my HTML:
<div class="row"> <div class="center"> <span class="text-danger label-promotion"><strong></strong></span> </div> </div> And my CSS, which sadly doesn't work this way, but I think you get what I'm trying to do:
.label-promotion:empty { display: none; } I want the <span> not to appear if is empty and I'd like to avoid JS for this. Is that possible?
<strong>in there. Does it have to be there? (edit) Sorry, misread the top of the question. No, you cannot affect the parent based on what the child is doing. That is that cascading part of Cascading Style Sheet