HTML and CSS Reference
Figure 6-3. With easy clearing, our float no longer colors outside the lines.
Another frequent need is to center an entire layout horizontally within the browser window.
While you might think this should work without resorting to CSS trickery, you would be
wrong. Happily, the workaround is a quick and easy one (and you can use it to center other
elements within your layout, not just the entire page—bonus!).
The only requirement is that you have a wrapper around your entire layout. For this
example, we'll call our wrapper element #wrapper :
Take a few seconds to imagine all your other layout elements where the ... is in the previous
code. Done? OK, now on to the CSS:
Setting text-align:center; on the body element centers the layout in IE/Win, thanks to
another one of its rendering bugs, while the min-width dimension (which should match the
dimension on #wrapper ) corrects a strange behavior in some slightly older versions of Mozilla