Can an input field have two labels?(输入字段可以有两个标签吗?)
问题描述
Mary 有一个小表格,它的字段就是这样标记的.
每当出现错误时,就会产生混乱.
我为每个输入字段都有一个标签……非常标准的事情.验证表单后,我将在表单顶部显示一个有用的小段落,详细说明缺少或不正确的信息.
I've got a label for each input field... pretty standard affair. After validating the form, I'm displaying a helpful little paragraph at the top of the form detailing what information is missing or incorrect.
我可以为同一个输入字段设置两个标签吗?一个在正确的表单中,一个在验证提醒文本中?有什么理由我不应该这样做吗?
Can I have two labels for the same input field? One in the form proper, and one in the validation reminder text? Is there any reason I shouldn't do this?
推荐答案
我假设这个问题是关于 HTML 表单的.来自规范:
I assume this question is about HTML forms. From the specification:
LABEL 元素可用于将信息附加到控件.每个 LABEL 元素只与一个表单控件相关联.
The LABEL element may be used to attach information to controls. Each LABEL element is associated with exactly one form control.
因此,每个表单控件可以被多个标签引用,但每个标签只能引用一个控件.因此,如果为控件添加第二个标签有意义(在您描述的情况下,确实如此),请随意添加第二个标签.
Thus, each form control can be referenced by multiple labels, but each label can only reference one control. So if it makes sense to have a second label for a control (and in the situation you describe, it does) feel free to add a second label.
这篇关于输入字段可以有两个标签吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:输入字段可以有两个标签吗?


基础教程推荐
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 我什么时候应该在导入时使用方括号 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- 动态更新多个选择框 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01