A popular technique to build a set fixed centered layout is wrap everything in the body in a div and set some CSS rules on it, for example:
<body>
<div id="wrap">
all content here
</div>
</body>
#wrap { width: 850px; margin: 0 auto; }
I was wondering, if there is a reason to add this extra wrapping div, since setting the same CSS rules on the body
works. Is it for compatibility with some browsers or just a tradition?
No. You do not need a "wrapper" div that so many use because they saw others do so. Use the body for that as you should. Setting CSS properties on the body was a problem in the past but not any longer.
It might work in some browsers, I don't think it'll work in all of them. Also, it's quite common to set a background on the body, then a separate one on the wrap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With