Is there a best practice concerning the nesting of label and input HTML elements?
label
input
classic way:
Both are correct, but putting the input inside the label makes it much less flexible when styling with CSS.
First, a is restricted in which elements it can contain. For example, you can only put a between the and the label text, if the is not inside the . Second, while there are workarounds to make styling easier like wrapping the inner label text with a span, some styles will be in inherited from parent elements, which can make styling more complicated. 0 讨论(0) 查看其它14个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复
between the and the label text, if the is not inside the . Second, while there are workarounds to make styling easier like wrapping the inner label text with a span, some styles will be in inherited from parent elements, which can make styling more complicated. 0 讨论(0) 查看其它14个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复
Second, while there are workarounds to make styling easier like wrapping the inner label text with a span, some styles will be in inherited from parent elements, which can make styling more complicated.