|
It is easy to center anything using a table. No need to specify dimensions of the inner box. This version shows width and height centering (within the gray box). The only change from the width-only version, is the addition of a height on CSS for ".centerit table".
Even in this era of CSS, it is appropriate to use a table for this purpose. Otherwise, you would need some tricky CSS, and some extra HTML, as demonstrated here. At least until the day when all browsers are fully compliant with modern CSS guidelines. And it is wise to support the main browsers that have been in use for the past two or three years. The main concern is when IE 6's usage becomes minimal.
VERSION: checking that this works when wrapped around sequence of floated divs (LI's in a UL).