[英]Does a label element have to be associated with a form?
From the documentation of a label
element : 从
label
元素的文档中 :
Attributes
属性
(...)
(......)
for
.for
。 Theid
of a labelable form-related element in the same document as the<label>
element.与
<label>
元素在同一文档中的与标签有关的元素的id
。
Ugh. 啊。 Must this be the
id
of an element related to a form
? 这必须是与
form
相关的元素的id
吗?
Why am I asking. 我为什么要问。 Well I have a
select
element that is not associated with any form
. 好吧,我有一个
select
元素,它与任何form
都不相关。 Value of this select
does not have to be sent to the server and even when it will, it seems cumbersome for me to do this by submitting a form
. 此
select
值不必发送到服务器,即使是这样,我也很麻烦通过提交form
来做到这一点。 Is this incorrect? 这不正确吗? Yet I would like to somehow describe what this
select
does, so I want a label
, but there is no form
, so am I allowed to place a label
? 但是我想以某种方式描述此
select
作用,所以我想要一个label
,但是没有form
,所以我可以放置label
吗?
Longer story, if you wish to know: Web game, players can build teams and enter battles with these teams. 更长的故事,如果您想知道:网页游戏,玩家可以建立团队并进入与这些团队的战斗。 Ultimately I want something more sophisticated, but for the sake of prototyping I now have a
select
element whose option
s are simply teams' names. 最终,我想要更复杂的东西,但是为了进行原型设计,我现在有了一个
select
元素,其option
只是团队的名字。 So when the player chooses a team, it is simply set as the currently active team. 因此,当玩家选择球队时,只需将其设置为当前活跃的球队。 Now they can enter the teambuilder to view it or queue in the matchmaker.
现在他们可以进入团队建设者进行查看或在媒人中排队。 If they modify the team and save it, then it will be sent to the server;
如果他们修改了团队并保存了,那么它将被发送到服务器。 and if they queue to battle the team will also be sent to server;
如果他们排队战斗,该团队也将被发送到服务器; but in both cases additional data sent alongside the team's ID will differ significantly, so I don't see how can I make this
select
a part of a form
that may be later submitted to the server. 但是在这两种情况下,随团队ID一起发送的其他数据都将有很大的不同,因此我看不到如何
select
form
中的一部分,然后可以将其提交给服务器。
Or do I need a form
element, even if its only purpose will be to wrap a single select
inside a single label
? 还是我需要一个
form
元素,即使它的唯一目的是将单个select
包装在单个label
?
That description does not imply that a label
must be associated with a form-related element that is a descendant of a form
via its for
attribute. 该描述并不意味着
label
必须通过其for
属性与作为form
后裔的form
相关元素相关联。 It's saying that it must be associated with an element that is typically used in forms. 也就是说,它必须与表单中通常使用的元素相关联。 Most, though not all, of these elements are also known as form controls .
这些元素中的大多数(尽管不是全部)也称为表单控件 。 Neither the
label
nor its associated control is required to be a descendant of a form
, let alone one that is to be submitted. label
及其关联控件都不需要是form
的后代,更不用说要提交的form
了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.