html – 为什么不允许使用样式表列?

前端之家收集整理的这篇文章主要介绍了html – 为什么不允许使用样式表列?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
W3 specifies表格列(包括< col>元素)只允许四个CSS规则 – 边框,背景,宽度和可见性。

有人知道这个决定背后的原因吗?如果你可以拥有边框和背景,为什么不是字体和颜色?

解决方法

Ian Hixie在这里详细解释: The mystery of why only four properties apply to table columns.相关报价:

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.

猜你在找的HTML相关文章