-3

":empty" works good when an element is empty. But if atleast it had a “space”, it doesn’t work. I understand it will not work as it is not empty. But my requirement is this.

I have a parent Div and an Empty Child Div within it. So the Height of the parent Div is ‘0’. Can i in some way use a css selector to select the parent Div. I need to clear out certain css properties like padding, margin on the parent Div if it’s height is ‘0’. I can’t use Javascript or Jquery for some reason. Is this possible.

/* :empty doesn't work here becuse by Div#test has some data inside it, but still its height is 0*/
#test:empty{
  display: none;
  }
<div id="test" style="padding: 5px;border: 1px solid;">
  <div></div>
</div>
A. Wolff
  • 72,298
  • 9
  • 84
  • 139

1 Answers1

1

CSS cannot ascend to parents, it can only descend into children.

You would need to use some form of Javascript/jQuery which you stated you "cannot use for some reason"

Bryan Zwicker
  • 522
  • 1
  • 4
  • 24