当html属性和css样式的功能重叠时 [英] When functionalities of html attributes and css styles overlap

查看:261
本文介绍了当html属性和css样式的功能重叠时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1)如果在CSS文件中,我们指定以下样式:

1) If inside CSS file we specify the following style:

td
{ text-align:center; }

在Html文件中,我们有

While in a Html file we have

<td align="right" … >

那么CSS文件中设置的值将优先于内联html属性,因此< c $ c>< td> 单元格将与中心对齐。

then value set in CSS file will take precedence over an inline html attribute and thus elements contained inside <td> cell will be aligned to the center.

a)所有html属性都一样吗?意味着如果CSS规则和html属性功能重叠,CSS规则总是优先?

a) Is same true for all html attributes? Meaning if a CSS rule and an html attribute functionalities overlap , will the CSS rule always take precedence?

BTW - 我知道我们通常应该使用CSS规则和html属性。

BTW – I know we should usually prefer using CSS rules vs html attributes

thanx

推荐答案

哪些定义集合,HTML属性或CSS属性优先?

Which set of definitions, HTML attributes or CSS properties, take precedence?

strong>教科书答案:

The textbook answer:

CSS属性优先于HTML属性。如果两者都被指定,HTML属性将显示在没有CSS支持的浏览器中,但是不支持CSS的浏览器中的任何效果。

CSS properties take precedence over HTML attributes. If both are specified, HTML attributes will be displayed in browsers without CSS support but won't have any effect in browsers with CSS support.

(参考: http://www.hwg.org/resources/faqs/cssFAQ.html

现实答案

这取决于,如果你想确定对于特定属性或属性集,您必须创建单元测试,并将这些测试应用于要验证是否符合教科书答案的特定浏览器,或者是否符合您的规范的特定

It depends, if you want to be certain for a specific attribute or set of attributes, you will have to create a unit test and apply those tests to the specific browser(s) that you want to verify for compliance with the "textbook" answer, or compliance to your specification for the specific project you are working on.

您已经暗示您知道某些HTML属性已被弃用,因此我不会在这里讨论这一点。

You already imply that you know certain HTML attributes are deprecated, so I will not belabor that point here.

这篇关于当html属性和css样式的功能重叠时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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