独立属性(如cellpadding)的CSS优先级 [英] css precedence of standalone attributes like cellpadding

查看:97
本文介绍了独立属性(如cellpadding)的CSS优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道通过'style'属性的内联样式优先于在外部CSS文件中指定的样式.但是像"cellpadding"这样的独立属性呢?示例行将如下所示:

I know that inline styles via the 'style' attribute take precedence over those specified in an external css file. But what about stand-alone attributes like 'cellpadding'? An example line would be like this:

<table cellpadding="4" class="list">

推荐答案

6.4. 4 CSS 2.1规范中非CSS表示提示的优先级表示:"UA可以选择遵循HTML源文档中的表示属性.如果是这样,则将这些属性转换为对应的CSS规则,其特异性等于0,并且将它们视为在作者样式表的开头插入.因此,它们可能会被后续的样式表规则所覆盖."

6.4.4 Precedence of non-CSS presentational hints in the CSS 2.1 spec says: "The UA may choose to honor presentational attributes in an HTML source document. If so, these attributes are translated to the corresponding CSS rules with specificity equal to 0, and are treated as if they were inserted at the start of the author style sheet. They may therefore be overridden by subsequent style sheet rules."

因此,在所应用的任何作者样式表中,任何相关设置均会覆盖cellspacing的效果.该属性将表的每个单元格的填充(沿每个方向)设置为指定值(以像素为单位).因此,如果您设置例如对于特定的单元格padding-right: 0,它将在其他方向上具有该右侧填充和4px填充.

So any relevant setting in any author style sheet being applied overrides the effect of cellspacing. The attribute sets the padding (in each direction) for each cell of the table to the specified value in pixels. So if you set e.g. for a particular cell padding-right: 0, it will have that right padding and 4px padding in other directions.

这篇关于独立属性(如cellpadding)的CSS优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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