On 2 Oct 2013, at 10:43, Greg Gamble wrote:

OK, I'll bite :-)

What is origin, weight, and specificity? I hear the terms and I think I get it ... but, to hear it from the Master would be great.

Well, the Master isn't available (something about a drum circle and looking for a police box key), but I'll take a swing at it. The details are here:

http://www.w3.org/TR/CSS2/cascade.html#cascade

Here's what I meant:

* Origin -- whether the rule comes from the author, the user, or the user agent. There's a precedence order defined in the specification, so that (for example) author rules always override user agent rules. That's why you saying 'strong {font-weight: normal;}' removes the boldface treatment even if there's a user agent rule that says something like 'h1 strong {font-weight: bolder;}'.

* Weight -- called "importance" in CSS 2.1. If a rule has been given '!important' then it wins over any non-important rule, period, end of story. Two conflicting rules that have the same weight (or importance), and thus have their conflict resolved through other means.

* Specificity -- how specific a selector is, which is figured out by counting the pieces and coming up with a value. Higher specificity trumps lower specificity, assuming the origin and weight are the same: thus two normal-weight author rules that conflict are resolved using selector specificity.

…and if, after all that, two rules are still in conflict, THEN the order they're written in matters. There's a little bit more to the story, once you take into account inheritance and the lack of a notion of element proximity in the document tree and so forth, but those are the core bits.

--
Eric A. Meyer - http://meyerweb.com/
______________________________________________________________________
css-discuss [css-d@lists.css-discuss.org]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to