Forum Moderators: open
there was no id element
When present, the value of this attribute must be the same as the value of the id attribute of some other control in the same document.
It couldn't point to any other line.
for = idref [CS]
This attribute explicitly associates the label being defined with another control. When present, the value of this attribute must be the same as the value of the id attribute of some other control in the same document. When absent, the label being defined is associated with the element's contents.
This is what bobriggs had quoted but he only took part of it.
But now my question is it says when its absent the label is defined by the associated element's contents so why does the last code kick and error? Or am I reading it wrong and it saying when FOR is absent not ID?
<LABEL>
First Name
<INPUT type="text" name="firstname">
</LABEL>
The content of the label is now First Name, so the input must come withing <label></label>
When the validator saw 'for', it tried to find an id somewhere else in the document. That id could have been on any line (ie, it didn't know which control you meant - assuming there are more controls) So it had to point to that line. The problem is 'Error: X' - should have given a better explanation.