Re: [css21] multiple ID attributes with the same value

Ian Hickson wrote:
>>>>Would it be possible that CSS 2.1 specifies something similar to
>>>>XPath 1.0[1]? Something in the lines of: "When multiple ID
>>>>attributes with the same attribute value are found only the first
>>>>should be considered significant."
>>>
>>>What does that mean?
>>
>>That in a document such as:
>>
>> <foo>
>>  <bar xml:id="xyz"/>
>>  <bar xml:id="xyz"/>
>> </foo>
>>
>>... with the following style rule applied:
>>
>> bar{ background:lime }
>> #xyz{ background:red }
>> bar#xyz:first-child{ background:lime }
>>
>>... there is no red.
> 
> Oh, I see. IMHO that would be bad, and is not what is implemented either.
> 
> Both elements have the ID "xyz", so both should match "#xyz".

Doesn’t that behaviour allow for misuse?

If Anne’s suggestion is followed, authors would not be able to use ID’s 
as class attributes. If this works as you suggested in actual 
implementations, even though invalid, people are going to (unknowingly) 
misuse it.

So, I agree with Anne that this would be a viable change. OTOH, there 
are probably already a ton of sites out there which do this incorrectly. 
And there is something to be said for an argument like that it’s not the 
task of CSS to make people form their documents well (then again, it 
couldn’t hurt).


~Grauw

-- 
Ushiko-san! Kimi wa doushite, Ushiko-san nan da!!

Received on Monday, 14 February 2005 12:48:13 UTC