Should i ad a container div to wrap around columns?

Greetings from Wetherby UK :slight_smile:

On this page & illustrated her I’d like to know why i should ad a div container to wrap around the columns. Some tutorials recommend it but why do i need to do it?

Thanks in advance,


There is no real need to add an extra wrapper around those two columns unless you are starting another series of floats and need then all to start afterwards without snagging and even so you could wrap the new element in the (cleared) wrapper anyway.

As long as you have set the following non floated element to clear:both then you should be good to go.

However, one benefit of wrapping floating columns is that you can contain them within that parent (overflow:hidden or some other mechanism) and then the top margins on elements that follow would work. Top margins on a non floated element that follows a float will not work as the margin slides under the float.

It all depends on context as there is no hard and fast rule but sometimes its nice to group elements so that you have a point of reference for the content within.

Thanks Paul :slight_smile: