Timeline for answer to What does "for" attribute do in an HTML <label> tag? by Jukka K. Korpela
Current License: CC BY-SA 3.0
Post Revisions
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 18, 2024 at 13:10 | comment | added | balu |
(continued) Regarding the link to MDN that I posted, there is also this other MDN page which does add a for attribute to the <label> even when the latter wraps the <input>. So I'm none the wiser. :(
|
|
| Sep 18, 2024 at 13:10 | comment | added | balu |
Update to my previous comment: I just ran into this again and realized that technique H44 in WCAG 2.1/2.2 no longer provides any example of a <label> wrapping an <input> to begin with, so I guess that explains why all the <label>s there carry a for attribute. So it seems the WCAG don't make any statement about whether or not to set the for attribute when the label wraps the input.
|
|
| Jun 25, 2024 at 15:29 | comment | added | balu | (continued) For instance, MDN's "Understanding the WCAG" says "The form element can be placed inside the <label>, in which case the association between the form element and the label is obvious from the structure." | |
| Jun 25, 2024 at 15:24 | comment | added | balu |
"the implicit association […] is not as widely supported as the explicit association via for and id attributes" -- The technique H44 in WCAG 2.0 you linked mentioned specific compatibility issues with JAWS 7.10 and Window-Eyes 5.5 on Windows XP with either IE 6 and Firefox 1.5. Now, almost 20 years after the release of Firefox 1.5, technique H44 in WCAG 2.1/2.2 no longer mentions such compatibility issues, yet it still suggests using an explicit for and it doesn't discuss implicit association, either. Does anyone know what the current state here is? Is implicit association still discouraged?
|
|
| Apr 16, 2021 at 5:46 | comment | added | cyberconte | The HTML specification dictates that ids need to be unique. Having duplicate ids is not supported and will have unintended consequences like what you're experiencing. | |
| Aug 1, 2019 at 6:19 | comment | added | LoveToCode | Hi, I have two elements with the same id but in different div, I added focus event using label for but in second element it is focusing on first element. <html> <body> <div id="first_div"> <label for="name">Name</label> <input type="text" id="name"> </div> <div id="second_div"> <label for="name">Name</label> <input type="text" id="name"> </div> </body> </html> | |
| Apr 26, 2018 at 13:13 | history | edited | Joseph Quinsey | CC BY-SA 3.0 |
The two examples in the question were reversed in November 2016
|
| Aug 13, 2015 at 19:00 | comment | added | ulty4life | +1 for talking about the semantic relationship and what it means beyond the functional clicking relationship. | |
| Aug 25, 2013 at 19:17 | history | answered | Jukka K. Korpela | CC BY-SA 3.0 |