Label

Critical - WCAG Level A

The accessibility issue at hand is the lack of proper labels for form elements. Each form input, such as text fields, checkboxes, and radio buttons, must have an associated label that describes its purpose. Without these labels, users relying on assistive technologies, like screen readers, may struggle to understand what information is required, leading to confusion and potential errors when filling out forms.

This matters significantly for users with disabilities, particularly those who are blind or have low vision. Screen readers read out the labels associated with form fields, allowing users to comprehend what data they need to enter. If a form element lacks a label, the screen reader may announce it as an unlabeled field, which can be frustrating and disorienting for users. Additionally, keyboard users may find it difficult to navigate forms effectively without clear labels.

To fix this issue:

  1. Identify all form elements: Review your form to ensure every input type is accounted for.

  2. Add <label> elements: For each input, create a corresponding <label> element. The for attribute of the label should match the id of the input it describes.

  3. Use descriptive text: Ensure that the text within the label clearly describes the purpose of the input field.

  4. Test with assistive technologies: After implementing labels, test the form using a screen reader to confirm that all fields are announced correctly.

Best practices:

  • Use semantic HTML where possible, such as wrapping inputs in <fieldset> and <legend> for groups of related fields.

  • Consider using ARIA attributes like aria-labelledby or aria-describedby when necessary, but these should not replace standard labels.

Common mistakes to avoid:

  • Omitting labels for certain input types (e.g., checkboxes, radio buttons).

  • Using placeholder text as a substitute for labels, which is not a reliable solution since placeholders disappear when users start typing, making it hard to remember what the field is for.

  • Forgetting to associate the label with the input using the for and id attributes correctly.