Home > other >  How to style divs which do not have any elements in it?
How to style divs which do not have any elements in it?

Time:09-22

I would like to know if I can select a div which does not have any elements in it in CSS.

For example:

HTML:

<body>
    <!-- div with some elements inside of it -->
    <div>
        ...
    </div>

    <!-- divs with nothing inside of them -->
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    </body>
</html>

If this was the body of my HTML code, I would like to select the last four empty divs.

Thanks in advance!

  • Related