Specificity of STYLE attribute

I think the rules for the specificity of the STYLE attribute [1] should
be changed (in the revised edition of CSS2, if possible, even though
this is a substantive change).

The current rule is that the style attribute has the specificity of a
single ID selector, i.e., 100, and should thus be overridden by
anything with specificity greater than 100.  No browser supports this.
I wrote a test [2] for the current rule, and NGLayout, Opera 3.51, and
MSIE 5.0 beta 2 all fail in the same way, by having the style attribute
override all the time (which is the behavior I want).  (Netscape
Navigator 4.5 failed in a strange way.)

I think the rule should be changed so that the STYLE attribute has a
specificity of 1000, so that it always wins.

Why do I think this should be the case?  Users expect this behavior,
and the old behavior may be a problem with the DOM.  Users of CSS
expect the STYLE attribute to win, I think.  I was surprised when I saw
the current rule.   Furthermore, if ways for manipulating the style of
a given element without adding stylesheet rules are added to the DOM,
as is mentioned in the DOM-Level-2 WD [3], then these methods would
probably result in a rule with the specificity of the STYLE attribute.
If the element in question were already matched by a rule with a
specificity greater than 100, the rule could not be overridden through
such DOM functions or attributes.  Giving the STYLE attribute
specificity of 1000 would create a consistent solution to this
problem.

David Baron

[1] http://www.w3.org/TR/REC-CSS1#cascading-order 
    and
    http://www.w3.org/TR/REC-CSS2/cascade.html#specificity
[2] http://www.fas.harvard.edu/~dbaron/csstest/sec060403b.html
[3] http://www.w3.org/TR/WD-DOM-Level-2/css.html#Level-2-CSS-unresolved-issues

Received on Saturday, 6 February 1999 14:26:19 UTC