使用
请原谅我问这个可能非常愚蠢的问题,但我的好奇心快要杀了我,而且我对此很陌生,但在标记中使用标签很重要,为什么?
即
<label for="birthdate">Birthdate:</label>
<input type="text" id="birthdate" name="birthdate" />
为什么我必须标记这个输入,为什么它对用户有益,为什么对将来的使用有益,或者是搜索引擎优化的事情。这就是我真正想知道的:)
Excuse me for the maybe very stupid question, but my curiosity is killing me, and plus I'm new to this, but are using labels important in your markup, and why?
i.e.
<label for="birthdate">Birthdate:</label>
<input type="text" id="birthdate" name="birthdate" />
Why must I label this input, why is it beneficial to the user, why is going to be beneficial for future use, or is it search engine optimization thing. That's what I really wanna know :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于多种原因,它很重要:
文本字段,内容很多
用户期望。
只是文本或跨度或其他东西,但是
你为什么会这样做?
It's important for a number of reasons:
text field, which is something a lot
of users expect.
just text or a span or something, but
why would you?
它有助于提高可访问性,例如屏幕阅读器。
此外,对于诸如复选框之类的内容,它允许用户单击标签而不仅仅是复选框本身(尝试一下!)。
It helps for accessibility, e.g. screen-readers.
Also for things like checkboxes it allows the user to click on the label and not just the checkbox itself (Try it!).
这对于可访问性很重要,因此使用屏幕阅读器的盲人可以轻松辨别哪个文本框用于哪个内容,因为否则他们的软件可能无法从页面结构中辨别活动文本框的用途。另外,单击标签将聚焦到相应的输入控件,这很方便。
It's important for accessibility, so blind people using screen readers can easily tell which text box is meant for which thing, since possibly otherwise their software cannot tell the purpose of the active text box from the page structure. Also, clicking on the label will focus the appropriate input control, which is convenient.
未来使用:
在输入 html 表单直接与数据库链接的情况下(发生在框架中),
因此输入表单变量直接表示数据库列。
因此,我们可以使用标签向用户显示简化的名称,而不是在表单中向用户显示数据库列名称。
Future use:
In a case where the input html form is directly linked with database ( happens in frameworks)
so the input form variables directly represent database columns.
So, instead of showing database column names to the user in the form, we can show simplified names to the user using Labels.