margin: 0 auto;
for horizontal centering should work fine for IE6+, but only as long as you are in Standards Mode. Make sure you include a Standards Mode doctype in your HTML, or you'll fall into Quirks Mode, where nothing works properly.
To find out whether a particular page is in Standards Mode, enter javascript:alert(document.compatMode)
into the address bar. CSS1Compat
is good; BackCompat
is Quirks.
For vertical centering without absolute-positioning, that top: 50%
only makes sense if the parent element has an explicit height. So if you are intending to push the top down to half of the browser height, then you'll need to specify 100%
height on each ancestor of the element, eg. at least:
html, body { height: 100%; }