HTML LABEL Without FOR Attribute and ID

by Parosa | 2020-08-10

There are two ways to associate a label with its controls (e.g. input element)

Implicit

Not Using label’s for attribute.

<label>
   First Name:
   <input type="text">
</label>

control’s id is not required

Explicit

Using label’s for attribute.

<label for="firstname">First name: </label>
    <input type="text" id="firstname">

The label’s for value should match the control’s id value.

Note that control’s id attribute is required. Since id is unique, each label is associated with only one control.

Source