Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

CSS | :empty Selector

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The :empty selector is used to select that element which does not contain any children (including text node). 

Syntax:

:empty {
    // CSS property
} 

Example: 

html




<!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>                   

Output: 

 

Supported Browsers: The browser supported by :empty selector are listed below:

  • Apple Safari 3.1 and above
  • Google Chrome 1.0 and above
  • Edge 12.0  and above
  • Firefox 1.0 and above
  • Opera 9.5 and above
  • Internet Explorer 9.0 and above
My Personal Notes arrow_drop_up
Last Updated : 11 Jul, 2022
Like Article
Save Article
Similar Reads
Related Tutorials