How to Center Web Pages

The Old Way with Tables

Example page center with tables >>

The New Way with CSS

html page

CSS

The proper way to center a block-level element with CSS is to setmargin-left: auto and margin-right: auto. This instructs the browserto automatically calculate equal margins for both sides, thus centering the div.

Example page center with CSS >>