Reputation: 4387
Is this valid
<label id="UserLNameLabel" />
?
vs this
<label id="UserLNameLabel"></label>
There seems to be some issue pulling the first version out of the DOM but both look correct in the designer and the browser.
Upvotes: 1
Views: 3184
Reputation: 6432
https://www.w3.org/TR/html/sec-forms.html#the-label-element
Tag omission A label element must have both a start tag and an end tag.
Upvotes: 4
Reputation: 943480
In XHTML it is valid (any element without content can use the self-closing tag syntax) but not HTML-Compatible.
In HTML it is invalid. From HTML 4:
<!ELEMENT LABEL - - (%inline;)* -(LABEL) -- form field label text -->
Note the two -
above. The first indicates that the start tag is required, the second that the end tag is required.
In either case it is pointless as it has no text content and is not associated with a form control (since it does not contain a form control and has no id attribute).
Upvotes: 2