Skip to content


Centering Fixed Width Content with CSS

This is quite easy to do. First, create your HTML:

<body>
   <div id="container">
      ...
   </div>
</body>

In this example, the div with the id of “container” is what we want to make centered and fixed width. Now for the CSS:

body
{
   margin: 0;
   padding: 0;
   text-align: center;
}

#container
{
   margin: 0 auto;
   width: 770px;
   border: 1px solid red;
}

Posted in General, Web Development.

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.