[whatwg] getElementsByClassName()

Ric Hardacre whatwg at cycloid.f9.co.uk
Fri Feb 3 06:26:37 PST 2006



Lachlan Hunt wrote:
 > Ric Hardacre wrote:
 >> Gervase Markham wrote:
 >>> If you have:
 >>>
 >>> <p class="foo bar">Fred</p>
 >>> <p class="bar foo">Barney</p>
 >>> <p class="foo baz bar">Wilma</p>
 >>>
 >>> which should be picked up by getElementsByClassName("foo bar")?
 >>
 >> this also raises the possibility of some confusion as the order of 
inheritance is important:
 >>
 >> foo
 >> {
 >>    color: red;
 >> }
 >>
 >> bar
 >> {
 >>    color: blue;
 >> }
 >>
 >> in the quoted example Fred and Wilma would be blue and barney red.
 >
 > According to which rules specified in CSS will that be the case? 
Given that CSS (assuming you meant to use class selectors instead), all 
three markup samples will be blue.  The order of the class names in the 
markup is irrelevant.  The order of the rules specified in the CSS is 
relevant and the latter rule of equal specificity takes precedence.
 >

just checked it, i was wrong, oops!

ric





More information about the whatwg mailing list