Calogero Alex Baldacchino wrote:
However, now I have a question. The 3rd step of the algorithm to
determine "the indicated part of the document" says,
"If there is an element in the DOM that has an ID exactly equal to
/fragid/, then the first such element in tree order is the indicated
part of the document; stop the algorithm here."
Shouldn't the id be unique in the whole document? Section 3.3.3.2 says,
"The||| id |attribute represents its element's unique identifier. The
value must be unique in the subtree within which the element finds
itself and must contain at least one character. The value must not
contain any space characters."
then follows,
"If the value is not the empty string, user agents must associate the
element with the given value (exactly, including any space characters)
[...]"
I think you're confusing parsing rules that conforming user agents must
follow to associate identifiers with elements (even when ids are
duplicated) with the authoring rules that conforming documents must
follow (ids must be unique). In general, the rules that user agents must
follow have to deal with non-conforming documents (i.e. the vast
majority of the web) too. They are generally patterned after the
(unwritten) rules that existing user agents follow, for backwards
compatibility reasons. Duplicated id attributes, sadly, are not that rare.
--
Benjamin Hawkes-Lewis