What is empty in CSS?


How to use empty css selector?

CSS :empty is the pseudo-class selector. If you will use any element and left any text or content then it will be an empty element. Also, If we are using comment in the any element then it will show as an empty element. below is the code for the css empty class.

<style> 

        p:empty {
          backgroundred;
          width150px;
          height30px;
        }
        div:empty {
          backgroundgreen;
          width200px;
          height50px;
        }
  </style>    
        
        <p>I am paragraph.</p>
        <p></p>
        <p>Other paragraph.</p>
        
        <div></div>
        <div>Learn anything</div>
        <br>
        <div><!-- this is html comment  --></div>




No comments:

Note: Only a member of this blog may post a comment.

Copyright Reserved to Anything Learn. Powered by Blogger.