为什么不允许样式表列? [英] Why is styling table columns not allowed?

查看:94
本文介绍了为什么不允许样式表列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

W3指定表格只允许使用四个CSS规则列(< col> 元素) - 边框,背景,宽度和可见性。

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?

推荐答案

Ian Hixie在这里详细解释:为什么只有四个属性适用于表格列的谜题。相关引用:

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


文本的颜色取决于其元素的color属性。除非指定,color属性(基本上)默认为inherit,这意味着获取父元素的值。

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".

单元格中,颜色由单元格的color属性决定,该属性取自从表中获取的行,从表的父级获取,依此类推。

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.

这篇关于为什么不允许样式表列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆