Search code examples
csshideselectorparent-childis-empty

Applying style to a parent block depending on the child's state


With the following block structure:

<div class="container">
    <div class="title"></div>
    <div class="subject"></div>
</div>

is it possible to hide (display:none) a .container if it's child .subject is empty? Thanks!


Solution

  • well... you could try to fake it... make title position: absolute and for container set overflow: hidden; container itself will only be visible if you put something into .subject tag. Like this: jsfiddle example