html - text-decoration 缺乏继承性的原因是什么?

标签 html css inheritance properties text-decorations

所以我读过the previous disccussion关于这个主题,我知道文本装饰是传播的而不是继承的,但是 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 的设计者当时并不希望属性激增。


很难证明这样的负面影响,但我不知道有任何其他属性以这种方式传播。

关于html - text-decoration 缺乏继承性的原因是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69713054/

相关文章:

javascript - 在密码字段中禁用密码屏蔽

javascript - Angular js指令: How to set selected value or default value

javascript - 使用 jQuery Tokeninput 时如何使匹配字符变为粗体+红色

c++ - 遍历抽象类的 vector

javascript - 同一时刻只有一个定时器在工作(html+js)

php - 如何将每个数字在不同字段中的电话号码插入数据库?

jquery - 如何通过任何平行边将子 div 放入父 div 中,并保持调整大小的比例?

javascript - 向下滚动然后向上滚动时如何隐藏div

javascript - 在这种情况下在 JavaScript 中实现继承 [更具体地说是 node.js]

java - java中多级继承中构造函数调用的顺序