Search code examples
htmlcsscss-tablescol

Why is styling table columns not allowed?


W3 specifies that only four CSS rules are allowed for table columns (with the <col> element) - border, background, width and visibility.

Does anyone know the reasons behind this decision? If you can have borders and backgrounds, why not fonts and colours?


Solution

  • Ian Hixie explains in detail here: The mystery of why only four properties apply to table columns. Relevant quote:

    The colour of text is dependent on the 'color' property of its element. Unless specified, the 'color' property (basically) defaults to 'inherit', which means "take the value of the parent element".

    So for some text in a cell, the colour is determined by the 'color' property of the cell, which is taken from the row, which is taken from the table, which is taken from the table's parent, and so on.

    What about the column? Well, the column isn't one of the cell's ancestors, so it never gets a look-in! And therein lies the problem.