Centered CSS Container

January 16, 2007

Method I am currently using for centering fixed width CSS layouts:

#container {
position: absolute;
top: 0;
left: 50%; /*puts margin starting point at the center of the page*/
width: 760px; /*this can be any width that you like*/
margin-left: -380px; /*this margin is negative one-half of the container width */

Tested in IE6, IE7, Firefox 1.5, Firefox 2.0 and Safari.