Forum Moderators: not2easy
I have my content in div tags. Each div has a width of 800px. I need to center each div in the page. How is this possible? Whenever I add text-align: center; to the CSS body it just centers the text in the divs and not the actual divs themselves.
Does anyone know a work around for this?
Thanks in advance for your help!
Wes
<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;
}
You could omit the margin and border on the body element if you wanted. Also, the border on the container is just to show where it is in this example. You would probably want to add text-align: left; to your container rules.