语义用<label>还出来一个<form>?

Semantic use of <label> also out of a <form>?

我对使用标签 label 有疑问。

我有一个 div 作为 小部件 模拟高级下拉列表。

<div class="control">
    <label class="description">Choose:</label>
    <div class="widget__list">...some other content...</div>
</div>

W3C 规范 (http://www.w3.org/TR/html401/interact/forms.html#h-17.9) 说:

The LABEL element is used to specify labels for controls that do not have implicit labels

(更新:请不要依赖上面的(过时的)引用。请参阅下面链接的 HTML5 规格

向上滚动到 "Controls" 部分 (http://www.w3.org/TR/html401/interact/forms.html#h-17.2) 我可以看到在 "control types" 的列表中有类型 菜单.

我想知道的是:

这些问题在语义上最正式的答案是什么?

编辑:

引用引用了HTML4规范,导致出现上述问题。 The current HTML5 specs for label gives already the answers that I needed (thanks ).

您的文档是 valid according to the W3C validator.

这意味着您的 label 案例在当前 HTML 标准中未被定义为错误。因此,您不必过多担心语义,只需按照此处的方式使用它——如果它对您来说很自然并且可以按预期工作。

Scrolling up to the "Controls" section (http://www.w3.org/TR/html401/interact/forms.html#h-17.2)

您不想将旧的 HTML4 规范用于任何事情。它于 1999 年出版。

当前 HTML 标准在 https://html.spec.whatwg.org/multipage/. The section of that spec on the label element is at https://html.spec.whatwg.org/multipage/forms.html#the-label-element

does my div-widget belong to the category of menu controls?

当前的 HTML 标准没有定义名为“菜单控件”的类别;所以 label 元素是否属于该类别并不重要。

am I using incorrectly the label element (not being in the context of a form), and should I maybe change it to span?

你没有用错。如果是,W3C 验证程序会将其标记为错误。换句话说,您的案例未被定义为当前 HTML 标准中的错误。所以你很高兴。