CSS :empty – define style for empty element

Css :empty pseudo-class represents an element that has no children at all. Few cases

  • <p></p> is considered empty
  • <div>hello</div> is not considered empty

Example – css :empty

<style type="text/css" media="screen">
div:empty {
  margin-top:20px;
}
</style>

<div>div1</div>
<div></div>
<div>div2</div>
refresh

Specification

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments