What's the “for” for in a label tag?

后端 未结 6 2007
臣服心动
臣服心动 2021-01-31 07:10

Just ran across a for parameter in an HTML label tag:


*         


        
6条回答
  •  粉色の甜心
    2021-01-31 07:28

    It specifies to which element that label is bound to. In your sample code the label is there for the required-firstname input field. If the user clicks on that label, the focus will go to the bound input field. It's a usability improvement and I think you'd be better off leaving it as is. It's a good practice.

提交回复
热议问题