Regarding the HTML Label#39;s quot;Forquot; Property(关于 HTML 标签的“For财产)
问题描述
考虑以下 2 行代码(复制自 w3schools.com > "HTML < label > for Attribute"):
Considering the following 2 lines of code (copied from w3schools.com > "HTML < label > for Attribute"):
<label for="male">Male </label>
<input type="radio" name="sex" id="male" />
我无法发现上述标签的for"属性的确切用途.如您所见,它当前设置为男性"(以匹配输入控件的 id).
I am having trouble discovering the exact purpose of the above label's "for" property. As you can see it is currently set to "male" (to match the id of the input control).
到目前为止,我所读到的只是上面的代码将标签与输入控件关联"和绑定".所以我的问题是,这到底是什么意思?
All I have read so far is that the above code will 'associate' and 'bound' the label with the input control. So my question is, what exactly does this mean?
将标签关联到输入控件的具体结果是什么?
标签和/或输入是否由于这种关联"而具有新的行为?
What exactly are the results of associating the label to the input control?
Does the label and/or input have new behaviours as a result of this 'association'?
推荐答案
通过 for
与控件关联的 label
将是可点击的.单击它选择控件.特别是对单选/复选框非常有用.它还对视障人士的屏幕阅读器的可访问性产生了影响.
A label
that is associated with a control via for
will be clickable. Clicking it selects the control. Highly useful with radio/checkboxes in particular. It also has accessibility implications for screen readers for the visually impaired.
这篇关于关于 HTML 标签的“For"财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:关于 HTML 标签的“For"财产


- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01