CSS Selector :empty








The :empty selector matches elements with no children including text nodes.

Summary

CSS Version
3

CSS Syntax

:empty { 
   style properties 
}

Browser compatibility

:empty Yes 9.0 Yes Yes Yes




Example

An example showing how to use :empty CSS selector.

<!DOCTYPE HTML> 
<html> 
    <head> 
        <style type="text/css"> 
        :empty { <!--from  w  w w  .  j av a 2s. co  m-->
            border: thin black solid; 
            padding: 4px; 
        } 
        </style> 
    </head> 
    <body> 
        <a href="http://java2s.com">Visit the java2s.com</a> 
        <a href="http://w3c.org">Visit the W3C website</a> 
    </body> 
</html>

Click to view the demo