Why are style sheet columns not allowed?

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

Does anyone know the reasons for this decision? If you have borders and backgrounds, why not fonts and colors?

+17
html css css-tables col
Jul 13 '09 at 12:13
source share
4 answers

Ian Hixie explains in detail here: The secret is why only four properties relate to table columns . Relevant quote:

The color of the text depends on the "color" property of its element. If not specified, the "color" property defaults to "inherit", which means "accept the value of the parent."

So, for some text in the cell, the color 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 parent table, etc.

How about a column? Well, a column is not one of the ancestors of cells, so it never gets a look! And this is the problem.

+10
Jul 13 '09 at 13:24
source share

Just a wild blow in the dark, based on my limited understanding:

I think styling through column-related elements is limited, because although <col> and <colgroup> represent columns of cells, they actually don't contain them (they are actually contained in <tr> s). In this case, problems of priority and specificity and cascading arise (since cascading can only be performed between contained / container elements) - when conflicting style rules from <tr> and <col> (which will be of the same level in the multiple inheritance hierarchy) arise - which cell should be used ?

As for why this part of several style attributes is allowed, though: no idea.

+8
Jul 13 '09 at 12:25
source share

One word: ambiguity. Cells must be children of the ranks; otherwise it will not be a table. But there is no column from which to descend. Using colspan means that one cell can be in two columns. Why not let the developer place a class on every nth cell?

If you look closely at the specification you are referencing, you will see attempts to resolve the ambiguity. The width property indicates the minimum; background takes backseat to row and cell; and border refers to the "conflict resolution algorithm". The only reason there is even an algorithm for border is that it is clear enough who should win (see Algorithm for details). But could you imagine how to try to figure out which color or font should β€œwin”?

+3
Jul 13 '09 at 12:39
source share

Perhaps because each row in the table does not have to display a cell for your column (e.g. due to colspan). Which column should this cell inherit its style? Just suppose.

0
Jul 13 '09 at 12:22
source share



All Articles