Forum Moderators: not2easy

Message Too Old, No Replies

Same style in Multiple CSS files

How to force my div tags to use style from a specific file

         

object

7:58 am on Feb 16, 2007 (gmt 0)

10+ Year Member



My page has many css files and the same styles are duplicated across these files. How can I make my div tags use style from a particular file

thx,
JJ

DanA

10:38 am on Feb 16, 2007 (gmt 0)

10+ Year Member



The last definition of a style will be applied.
You can't specify a stylesheet.

cmarshall

11:44 am on Feb 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What always gets me are specificity rules. I think SuzyUK did a post about specificity somewhere. I gotta run, so I can't look it up.

a.class{} trumps a{}, even is a{} is specified second. Same for a#id{} trumping a.class{} and a{}, etc. You can also bring containers into the mix for a tighter focus: div#navbar a{} usually beats a.class{} (I think). I don't usually do that, relying on classes and IDs. I use containers all the time to specify CSS.

In any case, the answer is in specificity. do a bit of looking up on it.

cmarshall

2:04 pm on Feb 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



UPDATE: This [stuffandnonsense.co.uk] is a very good (and entertaining) treatise on CSS specificity. It's about as simple as you can get, and very informative. It also links to several other more comprehensive sources.