The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Is a wrapper really necessary?

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #149887

    I’m working on a particularly complex layout… not in terms of aesthetics, just code.

    I experimented with different ways to do a wrapper but I find that less goes wrong when I just give elements a margin-right or a margin-left, depending on what side they’re on. Is this foolish? Must I have a wrapper? Or can I individually control everything on the page to make it all in the middle?

    I know this is more labor intensive but it may be my only choice.


    Is a wrapper really necessary?

    It depends on whether it is really necessary.

    I’m not being a smartmouth – seriously, it’s necessary for some layouts, but not for others. There’s no way to answer that question in absolute terms.

    If you have a particular layout in mind, and would like to share it, I’d be happy to help you figure it out.


    its NECESSARY if you want to create a clean and manageable layout.


    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.


    Well…. if you want a background image/color on the full page, and the contents have a fixed/maximum width and need to be centered, then you’d need a wrapper:

    Even though, technically you could just set the background on the HTML element and then center/space the BODY. So then you wouldn’t need one:

    But then the idea is the same.


    by “WRAPPER” if you mean page level wrapper I agree you can add width, margin, css etc on BODY tag…

    but for any other sub-sections or callouts or panes in the page… I think you cannot easily manage all their contents/children individually.
    So, group them and play with them…

    but many things have a wrapper-less solution.

    I believe there are only a few … like add width, margin, css etc on BODY tag

    I submit that they do the opposite. They create clutter.

    I agree only if you are referring to meaningless or redundant mark up in HTML

    If there’s “no other way,” fine; but you should be looking for another way.

    I didn’t mean “no other way,” there are ways which end up in extra CSS when you have different no of different elements to accommodate in a section…


    Can we just leave it at…NO, a wrapper isn’t necessary…until it is?


    +1 @Paulie_D

    @jurotek, yep, there’s a few ways to do it. I prefer the table-row approach because it allows a variable-height footer – something most approaches don’t (even those with wrappers).

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘CSS’ is closed to new topics and replies.