W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2006

[whatwg] getElementsByClassName()

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Sat, 04 Feb 2006 01:06:17 +1100
Message-ID: <43E36359.6030403@lachy.id.au>
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.

-- 
Lachlan Hunt
http://lachy.id.au/
Received on Friday, 3 February 2006 06:06:17 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:26 UTC