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?
From HTML label tag:
"The label element does not render as anything special for the user. However, it provides a usability improvement for mouse users, because if the user clicks on the text within the label element, it toggles the control.
The for attribute of the tag should be equal to the id attribute of the related element to bind them together."
The HTML <label>
tag has one special feature: It allows you to provide a for
attribute which links the label to an input field or other control, such that when the user clicks on the label, it is as if he clicked on the control.
eg:
<label for='mycontrol'>Label text</label> <input type='checkbox' name='mycontrol' id='mycontrol' value='1'>
This would mean that when the user clicks on the 'Label text', the checkbox would be toggled.
This is useful for accessibility, general usability, and also allows some tricks such as making a toggle control that doesn't look like a checkbox, but does contain one behind the scenes.
But aside from this for
feature, the <label>
element is basically the same as any other HTML element.
If you're not going to use the for
attribute, it may still be correct to use a <label>
element, for semantic reasons.