Making checkbox and radio labels clickable
A large number of (dare I say most?) sites do not make the labels clickable for their checkbox and radio inputs. It seems to be a huge usability gain for very little effort. Are there any compatibility/functionality/usability issues with using <label>
that would discourage developers from using this tag?
Edit: Even StackOverflow seems guilty of this, eg, when asking a question, the Notify daily of any new answers checkbox label is not clickable.
No reason other than laziness. <label>
s are essential for accessibility, and are also pretty handy for those of us who have poor aim with our mouse clicks :)
No, there are no issues with that, but unfortunately this is one of the most ignored html tags . Agreed, this tag is extremely important for accessibility reasons and what is more when it comes to layouts for small devices such as mobiles, you can't live without this.
The only difficulty I can think of is that your form controls need to have an ID attribute, and ID attributes need to be unique within your page.
If you were generating form fields programmatically, you would have to generate a unique ID for each of them within each page they appeared on. This could conceivably be an issue.
But generally, yeah, I think it's just that programmers don't have it in their heads.
In ASP.NET WebForms (or whatever it'd called), you want the AssociatedControlID
attribute on the <asp:Label>
element.
上一篇: 如何去页面上的特定元素?
下一篇: 使复选框和广播标签可点击