Re: [html5] Multiple IDs for an element?

Hi Jens,

On Jul 24, 2007, at 10:32 AM, Jens Meiert wrote:

>
> This is probably due to historical reasons (SGML?), but why isn't  
> it (or shouldn't it be) allowed to use multiple IDs for a single  
> element?
>
> Wouldn't that be valid (concerning the understanding that an object  
> might be unique not only in one, but several regards), and thus  
> probably something that we could consider for HTML 5 (and CSS 3, too)?
>
> Example:
>
>   <h2 id="intro special" />
>
> ... covering a certain "introduction" annotation that is at the  
> same time "special" (for example, including a foreword by a  
> different author in a fictitious "article of the month"). Similar  
> to classes, this could probably not only be formatted via "#intro"  
> and "#special" selectors, but also by "#intro#special", for example.
>
> Ad hoc, I see that change as an advantage concerning general  
> understanding of "uniqueness" as well as an improvement when it  
> comes to consistency. On the other hand, it likely imposes more or  
> less severe compatibility problems.
>
> This question and suggestion has almost certainly been discussed  
> before, but I couldn't find any useful references except for a CSS  
> test case that uses "id" and "xml:id" attributes on the same  
> element [1].
>

I don't know much of the history surrounding this. However, it would  
also cause problems with XML compatibility which says[1]: "An element  
type must not have more than one ID attribute specified."

I'm not clear on the us-e case you're describing here. For example,  
the ID values you supplied in your example look more like class names  
to me.

I'm not sure if this is at all related to your use-case, but I've  
often thought it would be useful to introduce a new global XML  
attribute with a new attribute data type such as pathid = PATHID. For  
a PATHID, they would be required to be unique only within a element  
node. In this way the pathid values could be strung together like in  
an xpath expression and traverse the tree to a unique element. At the  
same time, arbitrary document fragments could easily be combined  
without worrying about ID collisions. For example, in syndication one  
could include several articles together in a single document without  
worrying that PATHIDs collided and yet still be able to count on  
those PATHIDs for making relative DOM tree traversals. Is this at all  
related to your suggestion?

CSS could also develop a syntax to make uniquely specified PATHID  
selectors.

Take care,
Rob

[1]: <http://www.w3.org/TR/xml/#sec-attribute-types>

Received on Tuesday, 24 July 2007 16:12:30 UTC