[html5] wrapper or no wrapper

Brett Ryan brett.ryan at gmail.com
Tue Mar 4 13:41:22 PST 2014


Using floats to represent layout is actually not what floats are intended for in the first place. Floats are supposed to represent an element such as an image or an aside that is related to the main article where text will flow around.

Clear fixes for use around floats are a necessary bandaid for float styled elements. One of the biggest problems I see people trying to float something right so they place that element after the content they're floating against, where it should be before.

If you can, use an inline-block instead of floats, they don't require clearfix, and play nice with their container. One problem is the strange way margins get added from white space, which can be corrected by margin fixes or placing elements on the same line.

As for your original question regarding a container, why not use it? Changes to layout can be applied much easier without the need for wrestling with more float problems. Containing logical elements together is a good practice.

Sent from my iPhone

> On 5 Mar 2014, at 8:17, catsoul <catsoul at thinkplan.org> wrote:
> 
> A developer I know says that he abandoned use of wrapper or container divs in favor of each chunk of markup being it's own piece or container for floats, and those floats are only either float left or float right, with no clears used.
> 
> He says the benefit is no items attempting to jump up and to the right, and that the use of "clear" is hack. His idea is to use a wrapper *only* if you want you content area to have a shadow around it, or a border or some kind of background image throughout.
> 
> Thoughts on this?  is "clear" a hack? has the technique of using a wrapper as overall parent over?
> 
> thanks!
> 
> cat
> _______________________________________________
> Help mailing list
> Help at lists.whatwg.org
> http://lists.whatwg.org/listinfo.cgi/help-whatwg.org



More information about the Help mailing list