Do we really need a #container to center CSS layouts? I think not!

From the very beginning, I was taught that a container div should be used to center layouts. Apparently, the body element can itself be used to center the layout removing the need to use an extra wrapper.

Here is how we currently center layouts:

#container {
width:990px;
margin:0 auto;
}

but the container is not required at all so why use it? Here is how I center layouts:

body {
width:990px;
margin:0 auto;
}

As for the Background image, you can use the “html” element for that.

Check out the working example.

There has to be a valid reason for not using the body tag. Having learnt CSS just a few months back, I am fairly new to the language and might be missing something.

What do you think? Is the #container useless?

Join the discussion! Jump to the comments

Published on 11 Jan 10 under CSS

11 Interesting Conversations

Websites that link to this post

Any Comments? Go on, don't be shy