W3C home > Mailing lists > Public > www-style@w3.org > May 2001

Re: CSS to center a table?

From: todd fahrner <fahrner@pobox.com>
Date: Sun, 20 May 2001 18:03:07 -0700
Message-Id: <200105210103.f4L13Cu14509@dot.dreamhost.com>
Cc: www-style@w3.org
To: "Michael D. Crawford" <crawford@goingware.com>(by way of Al Gilman <asgilman@iamdigex.net>)
On Saturday, May 19, 2001, at 08:39 , Michael D. Crawford (by way of Al 
Gilman <asgilman@iamdigex.net>) wrote:

> Is there a way to use cascading stylesheets to center a table
> horizontally on a page?

yes. this isn't the forum for "how-to" questions (try 
comp.infostystems.www.authoring.stylesheets), but
<http://www.w3.org/TR/REC-CSS1#horizontal-formatting> has your answer. 
Set the left and right margins to "auto".

> What happens when I try using text-align on the table is that the text
> in the tables cells is centered within the cells.

this is correct: text-align describes how text is aligned *within* the 
element, not how the element itself is positioned.

> Here's my first attempt:
>
> In article.css:
>
> <!-- My CSS
> table.center {text-align: center}
> -->

replace with table.center {margin: auto}

I'm fuzzy right now on the details of how consistently this is supported 
in the dozens of UAs released since 1996; I know only that many get it 
wrong.
Received on Sunday, 20 May 2001 21:03:18 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:09 GMT