If you try to run an audit check from Google or any other services, you might get an accessibility error saying that, “Form elements do not have associated labels”.
Labels ensure that form controls are announced properly by assistive technologies like screen readers.
Assistive technology users rely on these labels to navigate forms.
Mouse and touchscreen users also benefit from labels because the label text makes a larger click target.
How to add labels to form elements
There are two ways to associate a label with a form element. Either place the input element inside a label element:
<label> Receive promotional offers? <input type="checkbox"> </label>
Or use the label’s for attribute and refer to the element’s ID:
<input id="promo" type="checkbox"> <label for="promo">Receive promotional offers?</label>
When the checkbox has been labeled correctly, assistive technologies report that the element has a role of checkbox, is in a checked state, and is named “Receive promotional offers?”
HTML label Tag
The label tag defines a label for several elements:
<input type="color"> <input type="date"> <input type="datetime-local"> <input type="email"> <input type="file"> <input type="month"> <input type="number"> <input type="password"> <input type="radio"> <input type="range"> <input type="search"> <input type="tel"> <input type="text"> <input type="time"> <input type="url"> <meter>
Screen reader users will read out loud the label, when the user is focused on the element. So that users who have difficulty clicking on very small regions (such as checkboxes) – because when a user clicks the text within the label element, it toggles the input (this increases the hit area).
The for attribute of the label tag should be equal to the id attribute of the related element to bind them together.
Credit: Web Dev
accessibility audit form Google html tags labels lighthouse page speed