[whatwg] Citing multiple <blockquote> elements in HTML5

Jonas Sicking jonas at sicking.cc
Wed Dec 3 11:39:09 PST 2008

> Otherwise, just let the id attribute be unique in the whole document, label
> any duplicate one as illegal and treat it as the empty string, so that one
> only method is enough and the DOM 3 undefined behaviour for 'getElementById'
> is no more problematic, being fired by non-allowed DOM structures (as don't
> care conditions). Such would be the easiest choice, although there might be
> any good reason to prefer allowing replicated ids inside the same document.

Note that having multiple IDs is quite common on real-world pages.
Especially ones that actively modify the DOM since often subtrees
containing nodes with IDs are cloned and reinserted. So if we do this
I expect quite a few pages to break.

In firefox we now always return the first element with the requested
ID. I think IE does the same. This seems equally reliably and much
less likely to cause page breakage or interoperability issues.

As for CSS, I believe in firefox we make all elements with a given ID
match the #foo selector. I don't have a strong feeling if this is the
correct thing to do, or just make the first one match. The only
concern I have is performance.

/ Jonas

More information about the whatwg mailing list