Oki. But there's more to this than immediately meets the eye. There are many things involved here. :)
First, use a doctype that puts all modern browsers in Standards Mode. That'll minimize the differences between them.
http://www.hut.fi/u/hsivonen/doctype.html
To center a box with CSS you can give it equal margins. Since the width of the box is known but the width of the viewport is not, we can use 'auto'.
(I just write the properties that matter.)
Code:
div#wrapper { width: 709px;
margin-left: auto; margin-right: auto }
That will do the trick in modern browsers, but not in IE5.x (or 6 if it's in Quirks Mode). The usual hack to fix that is to use 'text-align: center' on a block that contains the one you want to center. 'text-align' should only center text and text-level elements but IE gets this wrong and lets it center blocks too. BODY will do as container. Then we get this.
Code:
body { text-align: center }
div#wrapper { width: 709px;
margin-left: auto; margin-right: auto;
text-align: left }
/* Note that you have to undo the 'center' or all text will be centered. */
Now, because you have positioned the other boxes absolutely what we have done won't affect their placement one bit. Absolute boxes are out of the flow.
http://www.w3.org/TR/REC-CSS2/visure...opdef-position
As you can read there they are positioned relative their containing block. The containing block is in this case the root element, effectively the browser window.
http://www.w3.org/TR/REC-CSS2/visudet.html#x0
So, to make #wrapper the containing block we have to position it too. 'position: relative' (without parameters) does the trick and leaves #wrapper itself where it is.
Code:
body { text-align: center }
div#wrapper { position: relative;
width: 709px;
margin-left: auto; margin-right: auto;
text-align: left }
There. Note that the other boxes will now be positioned relative the edges of #wrapper not the browser window, so you'll probably want to change some of their offsets. I don't think you have to position them at all, but that's up to you. Using an offset in pixels bases on the text size is asking for trouble though. All browser except IE can easily resize the text. Since 8pt is small many people will do that. Height 100% doesn't work as you probably expect either. Sorry I can't explain it in a simper and more thorough way, but this is a BIG topic.
--
http://yupapa.com