Should I put input elements inside a label element?

前端 未结 14 1820
长情又很酷
长情又很酷 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 07:48

    I usually go with the first two options. I've seen a scenario when the third option was used, when radio choices where embedded in labels and the css contained something like

    label input {
        vertical-align: bottom;
    }
    

    in order to ensure proper vertical alignment for the radios.

提交回复
热议问题