html5 - Should I use the "for" attribute for <label> when I'm using it to label a text field or is it not necessary? -


when use checkbox or radio input, use attribute, needed when want label text input or input other checkbox / radio?

absolutely. not programmatically connect label text input (so screenreader users told text input for), increase 'click' area input, clicking (or tapping) on label set users focus corresponding field. if don't want use 'for' attribute whatever reason, can wrap text input in label well.

<label> text input    <input type="text" />  </label>

this have same effect increasing click area.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -