using text-align center in colgroup

Only a limited set of CSS properties applies to columns, and text-align isn’t one of them.

See “The mystery of why only four properties apply to table columns” for a description of why this is the case.

In your simple example, the easiest way to fix it would be to add these rules:

#myTable tbody td { text-align: center }
#myTable tbody td:first-child { text-align: left }

That would center all table cells, except the first column. This doesn’t work in IE6, but in IE6 the text-align does actually (wrongly) work on the column. I don’t know if IE6 supports all properties, or just a larger subset.

Oh, and your HTML is invalid. <thead> misses a <tr>.

Leave a Comment