Html 我可以在选择中使用标签元素吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10129696/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I use label element with select?
提问by P K
Can I use label element with select?
我可以在选择中使用标签元素吗?
Most of the places I see label example with input elements only.
我看到的大多数地方都只有输入元素的标签示例。
What does standard say about label association?
标准对标签关联有何看法?
Is it a valid HTML markup?
它是有效的 HTML 标记吗?
<label for="id_select"> Options </label>
<select id="id_select" autofocus="true">
<option value="1"> Option1 </option>
<option value="2"> Option2 </option>
</select>
回答by ThiefMaster
Yes, it's valid and works fine.
是的,它有效并且工作正常。
This attribute explicitly associates the label being defined with another control.
此属性将正在定义的标签与另一个控件显式关联。