3 ms·
Number 1 (and throughout the article) isn't right, the input should go inside the label. See https://developer.mozilla.org/en-US/docs/HTML/Element/input https:
by guycook 14y ago
Number 1 (and throughout the article) isn't right, the input should go inside the label.
See https://developer.mozilla.org/en-US/docs/HTML/Element/input https://developer.mozilla.org/en-US/docs/HTML/Element/input
Permitted content: None, this is a void element.
And https://developer.mozilla.org/en-US/docs/HTML/Element/label https://developer.mozilla.org/en-US/docs/HTML/Element/label for an example of doing it correctly
- bphogan 14y agoIt's completely legitimate to have an input tag outside of a label. Even the link you provided states: The HTML <label> Element represents a caption for an item in a user interface. It can be associated with a control either by using the for attribute, or by placing the control element inside the label element. As long as you use the for attribute, it's fine.
- guycook 14y agoYes, quite right. I probably wasn't clear enough there, but I was referring to this from the article: <input type="text" required><label>Social Security Number</label></input> Should be marked up as <label>Social Security Number<input type="text" required /></label> if you want to omit the 'for' attribute. Doing it the wrong way around will still render as you expect, but defeats the purpose as you won't get the click-to-activate behaviour.
- bphogan 14y agoAh yes, that's horribly, horribly wrong. :)