使用

发布于 2024-09-26 16:35:45 字数 281 浏览 1 评论 0原文

请原谅我问这个可能非常愚蠢的问题,但我的好奇心快要杀了我,而且我对此很陌生,但在标记中使用标签很重要,为什么?

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

情何以堪。 2024-10-03 16:35:45

由于多种原因,它很重要:

  • 单击标签可聚焦
    文本字段,内容很多
    用户期望。
  • 出于可访问性的原因,这很有帮助。
  • 用户如何才能知道哪个字段是哪个字段?你可以使用
    只是文本或跨度或其他东西,但是
    你为什么会这样做?
  • 它导致了更具语义的标记。

It's important for a number of reasons:

  • Clicking the label focuses on the
    text field, which is something a lot
    of users expect.
  • It's helpful for the accessibility reasons.
  • How else is the user going to know which field is which? You could use
    just text or a span or something, but
    why would you?
  • It leads to a more semantic markup.
染柒℉ 2024-10-03 16:35:45

它有助于提高可访问性,例如屏幕阅读器。

此外,对于诸如复选框之类的内容,它允许用户单击标签而不仅仅是复选框本身(尝试一下!)。

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!).

凉风有信 2024-10-03 16:35:45

这对于可访问性很重要,因此使用屏幕阅读器的盲人可以轻松辨别哪个文本框用于哪个内容,因为否则他们的软件可能无法从页面结构中辨别活动文本框的用途。另外,单击标签将聚焦到相应的输入控件,这很方便。

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.

夏了南城 2024-10-03 16:35:45

未来使用:

在输入 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文