使用<label>重要吗?在 HTML 中?

2022-01-25 00:00:00 forms labels html

对不起,这个问题可能很愚蠢,但我的好奇心让我很生气,而且我是新手,但在你的标记中使用标签很重要,为什么?

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?

<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 :)

推荐答案

这很重要,原因有很多:

It's important for a number of reasons:

  • 点击标签聚焦于
    文本字段,这是很多东西的用户期望.
  • 这对可访问性的原因很有帮助.
  • 用户如何知道哪个字段是哪个?你可以使用只是文本或跨度或其他东西,但是你为什么要?
  • 这会导致更多语义标记.

相关文章