[thelist] Centering divs in CSS

Taranis taranis at spittingllamas.com
Wed Nov 6 10:05:01 CST 2002


Jamie wrote:

>Try this (on a Mac, but fairly sure this works) - in addition to the
styles below, add:
>
>body { text-align: center }
>
>The only drawback is that you need to reset the text-alignment for all
of the divs themselves.

You can also do something like this:

<div id="container">
	<div id="content">
	Content Here
	</div>
</div>

And the styles are:
#container {
	text-align: center;
}
#content {
	text-align:left;
}

That way you don't have the whole body centered, but a container div.
Conceptually it works better for me, and it still allows you to do some
things in the body that aren't centered.

/alex
http://www.spittingllamas.com





More information about the thelist mailing list