Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Centering a table with style sheets in xhtml 1.1

OK, so now I've got my paragraphs justified properly, I want to center my tables.

The tables are inside a div, and the style sheet has "div {text-align:center}" which sets everything in the div to centered, except the tables.

Setting "table {text-align:center}" in the style sheet has no effect.

Of course, I can say align="center" in the table tag, but according to the xhtml validator ( ), the align property is deprecated and doing so will make my xhtml invalid.

Any ideas?

Thursday, February 27, 2003

Try this:

div {
    text-align: center;
    align: center;
Thursday, February 27, 2003

That works in IE6, but the tables are still left-aligned in Opera.  Maybe I'll check if there are any known issues with this.

Friday, February 28, 2003

1) You should be able to do this:

#CENTERED { text-align:center }


2) If this does not work, you can always use brute force (the old way):

<table width="100%">
<td align="center" width="100%">

Joel Finkel
Friday, February 28, 2003

*  Recent Topics

*  Fog Creek Home