< Back to Guides | Learn more at PaulJAdam.com >
Labels - Accessibility Quick Guide
Labels are used to identify the purpose of a form control. If the label is programmatically associated with the input then it will be spoken to the screen reader user when they tab to the input. Placeholders cannot be used as labels as they disappear and have very low contrast.
Image from Placeholders in Form Fields Are Harmful
Guidance
- All form controls must have a <label>.
- Label must always be visible, placeholder can't be used as a label!
- Set the <label> FOR attribute to equal the ID value of the input it controls.
- <label> tags wrapping the input and label text are acceptable but not preferred.
- There should be no orphaned <label> tags that are not connected to an input.
- <select> controls must have a <label>, their <option> text does not count as the label.
- Always use native <label> and <input> controls rather than custom ARIA controls! First rule of ARIA is DON'T USE ARIA! (unless you really need to)
- Make sure when you click the <label> text that the keyboard focus moves to the connected input.
Bad Example
Good Example