HTML - Correct way of coding a checkbox with a Label

后端 未结 3 2097
北荒
北荒 2021-01-04 10:29

I\'ve been using formtastic in order to generate HTML forms on rails applications. My question, however, is really HTML-related.

Today I found a strange behaviour on

3条回答
  •  爱一瞬间的悲伤
    2021-01-04 11:01

    Can anyone tell me why enclosing checkboxes inside their tag might be a good idea

    It might be a good idea because you could lose the id and for attributes in this case, making the markup simpler. When an is inside a , the connection between them is implicit. (See HTML4 section 17.9.1.)

    However, in practice this doesn't work in IE, so you lose that potential advantage.

    I can only assume in this case it's for layout/styling reasons.

提交回复
热议问题