是“为"如果目标输入嵌套在标签内,则 HTML 标签中必需的属性?
我注意到当您将输入元素放入标签元素时,HTML 标签标签不需要for"属性:
I've noticed that a HTML label tag doesn't need the 'for' attribute when you put your input element into the label element:
<label><input type="text">Last name</label>
但我想知道最好的做法是什么.有人可以帮我吗?
But I was wondering what's the best practise. Can anybody help me with that?
谢谢!
推荐答案
它用于屏幕阅读器等的可访问性,即
It's used for accessibility for screen readers and the like i.e.
use_the_label_element_to_make_your_html_forms_accessible
所以你应该使用它.这里有一个 链接 让您相信无障碍的重要性.
So you should use it. And here is a link to convince you about the importance of accessibily.
这里有一个小故事 - 让您的网站易于访问可以使所有用户受益 - 在我有一个女儿并使用婴儿车之前,市政当局为轮椅无障碍所做的努力一直让我感到惊讶.我认为网站遵循相同的规则 - 每个人都受益.
And here is a little story - making your site accessible can benefit all users - i always was amazed at the amount of effort civic authorities went to for wheelchair accessibilty until I had a daughter and use a push chair. I think websites follow the same rule - everyone benefits.
为争议道歉
相关文章