Using CSS to center page content

This example centers all the page content by wrapping it in a div element with an id of container. The div is then given a fixed width and auto margins:


#container
{
  width: 40em;
  margin-left: auto;
  margin-right: auto;
  font-size: 80%;
  font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif;
  background-color: #ffeecc;
  border: 1px solid #eeddbb;
  padding: 1em;
}
      

Return to the "Using CSS To Center Content" article