Is there a way to style a parent element if the child element is empty? For example:
Here, the <li> element is empty so I'd like the ul element to be styled with padding: 20px:
<ul class="list">
    <li></li>
</ul>
Is there a way to style a parent element if the child element is empty? For example:
Here, the <li> element is empty so I'd like the ul element to be styled with padding: 20px:
<ul class="list">
    <li></li>
</ul>
 
    
    You can't target a parent element with CSS. So it seems impossible to achieve this only with CSS.
Assuming you're using jQuery :
$('.list li:first-child').is(':empty').parent().css({"padding-top", "20px"});
