CSS Tutorial

CSS Style

CSS Layout Style

CSS Float Style

CSS Reference

CSS empty Selector (:empty)


What is :empty Selector?

CSS :empty selector select all element whose haven't any children element even not any text node.

Browser Compatibility

  • Google Chrome 2+
  • Mozilla Firefox 1.5+
  • Internet Explorer 9+
  • Opera 9.5+
  • Safari 3.1+

Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.

Syntax

General syntax of :empty selector,

:empty {
	property: value;
	property: value;
	...
}

div:empty {
	property: value;
	property: value;
	...
}

Example:

CSS :empty selector select all element whose haven't any children element or not any yext node.

<style type="text/css">
div:empty {
    width:100px;
    height:20px;
    background:#ff0000;
}
</style>
</head>
<body>
    <div></div>
    <div>first paragraph.</div>
    <div>Another one paragraph.</div>
</body>

Run it...   »

Example Result: