"margin-left: auto" and "margin-right: auto" is all that is needed to center an element in standards-compliant browsers.
However, it doesn't work in IE5/Win and earlier. Fortunately, there is a workaround. IE5 incorrectly centers block level elements with the property "text-align: center". So we apply "text-align: center" to the element containing the centered element, and use "text-align: left" on the centered element, in order to override the previous rule.
Also note: You should be able to replace "margin-left: auto" and "margin-right: auto" with the a shorthand such as "margin: auto" or "margin: 0 auto". The shorthands, however, are known to fail in certain versions of Opera. So it's recommended that you declare the left and right margins seperately. It may be redundant, but it's necessary redundancy.
Vertical Centering
Its vertical aligning that causes the problems. the vertical-align property will align things, like an image, in relation to the text but it is often required to vertically center whole DIVs for a layout. setting the top and bottom margins to auto should, in theory, work - but it doesn't. However, u-neek has worked out an example: