Whats the rendering difference between a span and label tag?

前端 未结 2 1435
青春惊慌失措
青春惊慌失措 2021-02-20 12:59

So I understand the functional difference between the span and label tags... however it appears there is also a rendering difference between the tags and I can\'t seem to figure

2条回答
  •  死守一世寂寞
    2021-02-20 13:40

    I can see no rendering difference with the default stylesheets in IE, Firefox, Opera or Chrome. It's possible a browser might choose to render it differently, but it's unlikely to be a significant difference.

    The main advantage of a label is that you can associate it with another form control (via containment or the for attribute). This can have accessibility advantages. Notably in the typical graphical-based browser you can click the label to focus the associated control (and tick it, for checkbox/radios, which is handy because otherwise it's quite a small target to hit). This reproduces established OS form widget behaviour.

提交回复
热议问题