错误消息:< span> vs< label> [英] Error Message: <span> vs <label>

查看:105
本文介绍了错误消息:< span> vs< label>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:

当您在HTML中显示错误消息时,您使用了哪个元素,< span> < label>

When you display an error message in HTML, which element do you use, <span> or <label>?

你可以列出每个人的一些优点和缺点,假设一些样式,例如颜色和边距通过他们的

Can you list some pros and cons for each of them, assuming that some styling, such as color and margin will be applied through their class?

应用

Thanks!

推荐答案

假设您的意思是与特定表单控件关联的错误消息,请使用< label>

Assuming you mean an error message associated with a specific form control, use a <label>.

语义参数有争议,因为在这种情况下它们并不明确,但实际的参数非常好。如果屏幕阅读器处于表单模式,则可能跳过非标签文本隐藏用户的错误信息。

The semantic arguments are subject to debate, as they aren't clear cut in this case, but the practical arguments win quite nicely. If a screen reader is in forms mode, it may skip over non-label text thus hiding the error messages from the user.

这篇关于错误消息:&lt; span&gt; vs&lt; label&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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