tags:

views:

17

answers:

1

Up to now I have two choices (maybe there are more outside):

  1. Set the width of body tag to a fixed length and set the horizontal margin of the body tag to auto. It makes all contents get horizontally centered.
  2. Create a wrapping div inside the body. Set the width of the wrapping div to a fixed length and set the horizontal margin of it to auto. It also makes any contents inside the wrapping div get centered horizontally.

I don't know, which one is better. Or if you have another alternative that you consider the best one, let me know.

+4  A: 

A wrapper div is more flexible, because you never know when you're going to want an element to not be centered. A couple months down the line if the site requires changes you'll be happy you had a wrapper div, ends up being less work because you can have siblings of the wrapper div and do what you want with them.

With that said, if it's a fairly simplistic trivial example/site, sure go ahead and 0 auto the body element.

meder