Tim Climis wrote:

On Sunday, January 16, 2011 03:52:39 am Alan Gresley wrote:
I did a few test and found that you can use just simple type
selectors also. This CSS,

body { background: lime; }

will override this.

<body bgcolor="#FFFFCC">

Nice to know.  I'd been assuming that bgcolor was similar to
style="background-color" in specificity.

The presentational attribute bgcolor is equivalent to a style sheet rule that appears at the start of an author style sheet, with specificity 0 by definition, see http://www.w3.org/TR/CSS2/cascade.html#preshint

The text there is confusing and I had to read it a few times (and read the nice illustrative discussion http://dbaron.org/css/user/cascade#noncss ) before I recollected why it sounds so weird: It says, without emphasizing this, that presentational attributes are translated into rules in an author style sheet. A little later, it says that font[color] { ... } does not override <font color=...> markup in HTML documents - without emphasizing that the example discusses the rule in a user style sheet.

When we consider rules in an _author_ style sheet (or, as I would rather call them, document style sheet - i.e. a style sheet included or referred to in a document), then any of them overrides any presentational attribute. Even if the rule had specificity 0, it would still win the one (conceptually) constructed from the presentational attribute: when both rules have specificity 0, the latter wins.

But if you wish to "beat", say, <body bgcolor="#FFFFCC"> using a _user_ style sheet, you need !important. That's the only way for a user style sheet to win a rule in an author style sheet.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
______________________________________________________________________
css-discuss [[email protected]]
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