Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💪第6期第4题:form表单中的label标签的作用? #40

Open
LinDaiDai opened this issue Jun 30, 2020 · 0 comments
Open

💪第6期第4题:form表单中的label标签的作用? #40

LinDaiDai opened this issue Jun 30, 2020 · 0 comments
Labels

Comments

@LinDaiDai
Copy link
Owner

form表单中的label标签的作用?

label标签不会向用户呈现任何特殊效果,它的作用是为鼠标用户改进了可用性。

也就是说当你使用了一个label标签和一个input绑定起来之后,点击label标签上的文字就会自动聚焦到input上。

如下:

绑定的方式:

  • label标签上设置for属性
  • input标签上设置和for属性一样的id

例如:

<label for="username">username:</label>
<input type="text" name="username" id="username"/>

这里有两点需要注意的:

  • 这两个标签不一定非要在form标签内才会生效
  • for是和id对应的,并不是和name
@LinDaiDai LinDaiDai added the HTML label Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant