Forum Moderators: not2easy

Message Too Old, No Replies

importing styles

         

tonynoriega

4:09 pm on Feb 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



which takes precedence?

a page calls a style sheet via link href, styleA.css

styleA.css imports styleB.css: @import "styleB.css";

they both have the same class in their respective stylesheets...

in styleA.css we have:

.maincolleft {
width: 239px;
margin: 0;
padding: 0 0 15px 0;
float: left;
}

.maincolright {
width: 300px;
}

in the imported stylesheet styleB.css we have:

.maincolleft, .maincolright {
width: 244px;
}

which will take effect and overide the other?

D_Blackwell

3:14 am on Feb 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is my understanding, though I may be corrected, that the @import has a higher priority than <link>. However, if there is a possibility of multiple conflicts, then you will want a very thorough understanding of cascade priority.

[w3.org...]

swa66

9:51 am on Feb 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The CSS2.1 reference is
[w3.org...]

Note it changed from the CSS2 version referenced above.

Basically the standard doesn't make a difference between the different author stylesheets in the cascade.

It the specificity makes the @import more specific, it wins.

If the specificity doesn't make a difference, that only leaves source order: which is coming first will loose out, and since your @import has to come at the top of the css file ... there is no chance the @import should win.
See point 4 in [w3.org...]

But I'd be careful relying on such things, you never know how a browser crafter interpreted things ... or if they even bothered to follow the standard.