Associating a <<strong>label</strong>> with an element offers some major advantages:
What is label in html. It adds a label to a form control such as text, email, password, textarea etc. When writing in html, the <<strong>label</strong>> tag is used to create labels for items in a user interface. Um elemento html <<strong>label</strong>> representa uma legenda para um item em uma interface de usuário.
It increases the clickable area, as. This value must be the same as the value in the input control's id. Last_name clicking the label will focus on the input with the id equal to last_name.
A label can also be bound to an element by placing the element. Html label acts as a caption for a specified element. In this case, the input and label are implicitly associated.
The html tag also supports the following additional attributes −. Defines which control the label is associated with. Specifies the input control that this label is for.
The for attribute of the <<strong>label</strong>> tag should be equal to the id attribute of the related element to bind them. It is used with input type checkbox or redio to select on label click. It contains the value i.e element_id which specify the id of the element that the label is bound to.
If the values of the for attribute of the. It helps assistive technology attach a label, which is otherwise anonymous, to an html element. The <<strong>label</strong>> tag is used to specify a label for an element of a form.