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

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

问题描述

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.

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

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