CSS | :empty Selector
The :empty selector is used to select that element which does not contain any children (including text node).
Syntax:
:empty {
// CSS property
}
Example:
<!DOCTYPE html> <html> <head> <title>empty selector</title> <style> h1 { color:green; } div:empty { width: 150px; height: 20px; background: green; } </style> </head> <body> <center> <h1>GeeksforGeeks</h1> <h2>:empty selector</h2> <div></div><br> <div>A computer science portal for geeks</div> </center> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browser supported by :empty selector are listed below:
- Apple Safari 3.2
- Google Chrome 4.0
- Firefox 3.5
- Opera 9.6
- Internet Explorer 9.0
Recommended Posts:
- jQuery | :empty Selector
- PHP | empty() Function
- D3.js | d3.set.empty() Function
- D3.js | d3.map.empty() Function
- CSS | empty-cells Property
- Best way to initialize empty array in PHP
- How to empty an array in JavaScript?
- How to check an object is empty using JavaScript?
- Check if an array is empty or not in JavaScript
- Program to remove empty array elements in PHP
- JavaScript | Remove empty elements from an array
- How to check an HTML element is empty using jQuery ?
- How to check empty/undefined/null string in JavaScript?
- CSS | * Selector
- CSS | ::before selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



