Should I put input elements inside a label element?

前端 未结 14 2050
长情又很酷
长情又很酷 2020-11-22 07:24

Is there a best practice concerning the nesting of label and input HTML elements?

classic way:



        
14条回答
  •  忘掉有多难
    2020-11-22 08:03

    If you include the input tag in the label tag, you don't need to use the 'for' attribute.

    That said, I don't like to include the input tag in my labels because I think they're separate, not containing, entities.

提交回复
热议问题