What is the spec behavior for two conflicting CSS styles from an external file? How well do browsers support this?
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.
精彩评论