【问题标题】:Can I use label element with select?我可以将标签元素与选择一起使用吗?
【发布时间】:2012-04-25 03:50:57
【问题描述】:

我可以在 select 中使用 label 元素吗?

我看到的大多数地方都只有输入元素的标签示例。

标准对标签关联有什么看法?

它是一个有效的 HTML 标记吗?

<label for="id_select"> Options </label>
<select id="id_select" autofocus="true">
  <option value="1"> Option1 </option>
  <option value="2"> Option2 </option>
</select>

【问题讨论】:

  • 有默认选项,值为 -1 类似于 ,如果你喜欢,你可以有标签

标签: html label html-select w3c-validation


【解决方案1】:

是的,它有效且工作正常。

此属性明确地将正在定义的标签与另一个控件相关联。

http://www.w3.org/TR/html401/interact/forms.html#h-17.9.1

【讨论】:

    猜你喜欢
    • 2012-06-29
    • 2015-06-05
    • 1970-01-01
    • 2011-09-04
    • 1970-01-01
    • 2011-03-18
    • 2011-12-06
    • 1970-01-01
    相关资源
    最近更新 更多