Why use

前端 未结 8 2023
时光说笑
时光说笑 2020-12-13 23:58

From a presentation perspective, if I write a text between a tag it looks identical as to if I hadn\'t.

So, why do we use this tag at all?

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 00:37

    HTML is not about presentation. It is a way of describing data. If you have some text that represents a label for an input, you wrap it in label tags not for presentation but because that's what it is. Without the label tag, that text is almost meaningless. With the label tag and its for attribute (or not*) you are providing meaning and structure and forming a relationship between your markup that can be better understood by computers/parsers/browsers/people.

    * you don't necessarily need the for if you wrap the label around the input:

提交回复
热议问题