Need some help with centering


I have created a few blocks using css but I can’t seem to center them on the page. Take a look at the testpage here:

Take a look at the code. I can only float to the right or float to the left. Too bad there isn’t a float center command! Any one knows how I can center these boxes using css?

There actually is a fake float center in this quiz.

However that’s only trickery ;).

You can center floats via something like this?

The #setofboxes div is not centering because it doesn’t have a set width (so it’s centering at 100% width…)

Rather than use <center> (which is out of date) the best way to center items is ike this:

#setofboxes {width: 540px; margin: 0 auto;}

Auto left and right margins centers an element with set width.

Yep, that’s it. Thank you very much!!

Just note that I make the div wider than necessary to account for the default margins and paddings, which it would be good to tidy up so that the content is tryly centered. :slight_smile: