On 09/28/2009 07:35 AM, Emanuele D'Arrigo wrote:
> div[style="color:blue"] {color:red}
> div[style="color:red"] {color:blue}
> 
[snip]
> div's color is set to blue which the css-handling
> functionality then sets to red which is then set back to blue again
> and so on, ad infinitum? Sorry if it's a bit of a silly question...

Hi Manu,

These rules wouldn't create a loop, for a more basic reason than the
specificity issue that Martijn brought up: the [style="color:blue"] only
matches elements using the *style attribute*, not the computed style.
(You seem to have confused those two -- the style attribute is a standard
HTML attribute, and it doesn't change, aside from direct modifications via
scripting.  The Computed Style, on the other hand, includes the results of
the whole style cascade.)

e.g. consider this element:

  <div style="color:blue"></div>

*Only* your first rule would ever apply here, because the element's style
attribute exactly matches that rule's selector.  Now, even if the first
rule changed the computed style[1], it won't change the element's *style
attribute*.  So your second CSS rule *never* applies to this example div,
and there's no loop.

~Daniel

[1] In this case, it won't actually change the computed style, because of
the rule-specificity priorities that Martijn brought up.
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout

Reply via email to