Skip to main content

label-orphaned

Ensures that the <label> element corresponds to a form control

Severity: Moderate

Description

A <label> is orphan if it is not associated with a form control in the HTML code. <label> has a for attribute, and form controls have an id attribute. If the value of the ‘for’ attribute of a <label> equals the ID of a form control, then the two correspond.

Why is it important?

If a <label> does not correspond to a form control, it can confuse assistive technology like screen readers and can have a negative impact on the overall user experience.

Example

Here’s an orphaned label:

HTML
Copy icon Copy snippet

Label without input

Here’s the corrected code:

HTML
Copy icon Copy snippet

Label with input

How to fix?

Link the <label> to the relevant form control using its ID. Or, if the <label> is unintended, remove it.

Reference

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Download Copy