开发者

What is the spec behavior for two conflicting CSS styles from an external file? How well do browsers support this?

开发者 https://www.devze.com 2022-12-30 05:14 出处:网络
Suppose I have two files containing styles, a.css and b.css.I import them into my page in the <head> section.Both of these external fi开发者_StackOverflow中文版les define a style for the class .

Suppose I have two files containing styles, a.css and b.css. I import them into my page in the <head> section. Both of these external fi开发者_StackOverflow中文版les define a style for the class .someclass. Which one takes precedence? Is there any guarantee based on the order of the imports for css files that will state which style should be used?


They are cascading style sheets. Later definitions with the same specificity override earlier ones. More specific definitions take precedence over less specific definitions.

You can find exactly how the standard defines it (for CSS2) at http://www.w3.org/TR/CSS21/cascade.html.

0

精彩评论

暂无评论...
验证码 换一张
取 消