Styling CSS tables

Wednesday, September 17th, 2008

I recently ran into the issue of how to style tables in HTML/CSS. For tabular data, a table makes the most sense. However, I still want the dang thing to look nice. To let the columns distribute evenly, I use this CSS code:

    table {        table-layout:fixed;        width:100%;    }

Then, when I want to limit the size of my columns, I add a specific class to the column. All the other columns evenly distribute themselves among the remaining width.

    table {        table-layout:fixed;        width:100%;    }    th.data {        width:50px;    }