How to center a page, example 1

The simplest way of centering a block level element is by giving the element a specific width (e.g. 700px, 20em, or 50%) and setting both left and right margins to auto.

On this page, this looks like this:

#container{
	width:500px;
	margin-left:auto;
	margin-right:auto;
}

If you are viewing this page with IE 5, you'll see it stuck to the left of your window, while in other browsers, it's centered, and it stays centered when you make your window wider or narrower.

IE 5 needs a different method to center block level elements.

next: ex.2: a centered page in IE 5 but not the other browsers


1) Internet Explorer 5 for Windows, not Macintosh.