CSS container div not getting height

Add the following property:

    overflow: hidden;

This will force the container to respect the height of all elements within it, regardless of floating elements.


Recently, I was working on a project that required this trick, but needed to allow overflow to show, so instead, you can use a pseudo-element to clear your floats, effectively achieving the same effect while allowing overflow on all elements.

    clear: both;
    content: "";
    display: block;


Leave a Comment