text-decoration 没有继承性的原因是什么?

What is the reason for the lack of inheritance of text-decoration?

所以我读过 on this topic and I understand that text-decoration is propagated instead of inherited, but the spec 没有说 为什么 。我试图更好地理解为什么会这样,以及为什么定位很重要。这种行为有什么好处?我对此感到惊讶,因为它不直观。在 CSS 中还有其他我应该注意的例子吗?

考虑这个标记,它早于 CSS。

<strike>The <a href="http://example.com/">example</a> is here.</strike>

<strike> 默认为 text-decoration:line-through,而 <a href="..."> 默认为 text-decoration:underline。在 CSS 之前,单词“example”将被加下划线和删除,因此 CSS 需要能够实现相同的效果。为此,规范编写者选择 text-decoration 积累而不是继承。

替代方案是为每个 text-decoration 值赋予其自己的 属性。 CSS 之父 Håkon Wium Lie 在 message to the www-style mailing list in May 1997 中解决了这个问题:

There is no easy way to turn off blinking without also throwing out other values set on the text-decoration property. This was sacrificed for the sake of brevity -- the alternatives would be to have separate binary properties for all values on 'text-decoration'.

当时设想 text-decoration 将扩展为拥有超过其最终拥有的四个装饰 - several had already been dropped from the draft spec.

所以你知道了,CSS 的设计者当时不希望属性激增。


很难证明这样的否定,但我不知道任何其他以这种方式传播的属性。