Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

browser

css

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 files 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?

like image 948
aw crud Avatar asked Jan 22 '23 02:01

aw crud


1 Answers

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.

like image 101
tvanfosson Avatar answered Feb 14 '23 11:02

tvanfosson