Home › Forums › CSS › [Solved] Is a wrapper really necessary? › Reply To: Is a wrapper really necessary?
Some thoughts:
@JoshWhite – For managing basic document styles (e.g., width and margins), you can style the body
. There’s no need to wrap everything with another element.
The only thing I’ve ever found a wrapper (meaning, a whole-layout wrapper) necessary for is certain “sticky footer” implementations (before I found this, that is). Now, I’m not saying that you can do “anything” without a wrapper – but many things have a wrapper-less solution.
Sometimes individual modules/ layout components will need a wrapper. But even where a wrapper is required, there is often a way to use a “natural” element as the wrapper – removing the need for an extra element. (After all, any discrete content should already be marked up in some sectioning element.)
@sadunaresh – I disagree that wrappers make layouts “clean” and “manageable” – in fact, I submit that they do the opposite. They create clutter. If there’s “no other way,” fine; but you should be looking for another way.
@Taufik – don’t “forget about box-sizing”! It’s just about the only thing IE got right. Sizing most elements as “border-box
” solves a lot of problems, not the least of which is all the complicated calculations you mention with padding and border size. It is also just about universally available – all major browsers from IE8 on up, and IE7- use the border-box model in the first place.