输入栏可以有两个标签吗? [英] Can an input field have two labels?

查看:143
本文介绍了输入栏可以有两个标签吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

玛丽有一个小表格,它的标签是这样的字段。

每当一个错误进入,混乱就会播下。



每个输入字段都有一个标签......非常标准的事情。
验证完表单后,我在表单顶部显示一个有用的小段落,详细说明哪些信息缺失或不正确。我可以为同一个输入字段使用两个标签吗?一个在表格中,另一个在验证提示文本中?是否有任何理由我不应该这样做?

解决方案

我假设这个问题是关于HTML表单的。来自规范


LABEL元素可用于将信息附加到控件。每个LABEL元素只与一个表单控件相关联。


因此,每个表单控件都可以被多个标签引用,但每个标签都可以仅引用一个控件。因此,如果为控件添加第二个标签(以及您所描述的情况),则可以随意添加第二个标签。


Mary had a little form, and it's fields where labeled just so.
Whenever an error crept in, confusion it would sow.

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?

解决方案

I assume this question is about HTML forms. From the specification:

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.

这篇关于输入栏可以有两个标签吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆