Previous Message
Next Message

Re: [css-d] Center aligning tables with CSS

Sent by Rijk van Geijtenbeek on 25 January 2002 05:05

On Friday, January 25, 2002, Eric wrote:

> At 19:55 -0800 1/24/02, Michelle wrote:

>>I cannot figure out how to center-align a table within CSS so that my
>>page still validates as XHTML strict.  The only option for centering
>>I've been able to find is 'text-align: center'.  When I div align
>>center, I don't validate properly.  Help!

>     <table style="width: 50%; margin: 0 auto;">

> By setting an explicit width value, and both the left and right 
> margins to 'auto', you get centering[1].  'text-align' only applies 
> to the alignment of inline content, not entire block-level elements, 
> which is why it isn't centering your table.

This will be a FAQ on this list, as it is on any list that discusses

The "definitive" answer on centering with CSS can be found here:

It's a Wiki, so modify the page if you find anything that's

 Rijk                            [EMAIL-REMOVED]

Mot du Jour:
A camel is a horse planned by committee.
Previous Message
Next Message

Message thread: