hail2u / html-best-practices

For writing maintainable and scalable HTML documents
4.12k stars 439 forks source link

Discussion: Omitting `for` attribute in 'input' element isn't a good practice #42

Closed jonathanlinat closed 7 years ago

jonathanlinat commented 7 years ago

As titled, omitting for attribute in input element ISN'T a good practice.

As mentioned by MDN, you should use this attribute because some assistive technologies do not understand implicit relationships between labels and widgets.

hail2u commented 7 years ago

This test proves that wrapping input element with label element is safe. I write this practice based on this test.

Your quoted paragraph was written on 2012. It’s too old. If you find at least one assistive technology that does not support this markup, tell me here and re-open this issue. I’ll fix this practive. Thanks!

jonathanlinat commented 7 years ago

Hey Kim :)

Your quoted paragraph was written on 2012.

YOUR quoted test is old (2012) and use old versions of assistive technologies. My quoted doc has been last updated on May 17, 2017.

Here proper docs about label and input and their association:

And the most updated test you can find nowadays.

hail2u commented 7 years ago

Yes, test is old. However, there is no regression here (for now).

WCAG Note, WebAIM document, and the test you refer proves that label element with for attribute is OK, but does not proves that wrapping input element with label element is not OK.

Is there a platform that does not support this markup?