Reputation: 46341
We all know that in HTML, an element ID is (and must be) unique.
From the standard:
The value must be unique amongst all the IDs in the element's home subtree and must contain at least one character.
Yet in the same standard, the for
attribute in the <label>
element it reads:
If the attribute is specified and there is an element in the Document whose ID is equal to the value of the for attribute, and the first such element is a labelable element, then that element is the label element's labeled control.
That would mean there could be more then one element with an ID equal to the value of the for
attribute.
So which is it? Unique - or not?
Upvotes: 0
Views: 136
Reputation: 10572
It's covering the case where someone may not have made a unique id, since really there isn't anything hard preventing anyone from breaking standard, and specifies the behavior in such a case. Basically a secondary line enforcing the idea that there should only be 1 id with a certain value.
Upvotes: 3