A form allows users to enter information into a page.
General accessibility guidance for forms
- Customize accessibly. As you customize these templates, make sure they meet the accessibility guidelines in this introduction and as described for each control.
- Don’t control element order with CSS. Display form controls in the same order in HTML as they appear on screen. Don’t use CSS to rearrange the form controls. Screen readers narrate forms in the order they appear in the HTML.
- Align validation with inputs. Visually align validation messages with the input fields, so people using screen magnifiers can read them quickly.
- Use proper markup. Group each set of thematically related controls in a fieldset element. Use the legend element to offer a label within each one. The fieldset and legend elements make it easier for screen reader users to navigate the form.
- Use legends. Use a single legend for fieldset (this is required). One example of a common use of fieldset and legend is a question with radio button options for answers. The question text and radio buttons are wrapped in a fieldset, with the question itself being inside the legend tag.
- Embed multiple fieldsets and legends for more complex forms.
- Use simple vertical layouts. Keep your form blocks in a vertical pattern. This approach is ideal, from an accessibility standpoint, because of limited vision that makes it hard to scan from right to left.
Known issues with screen readers
- VoiceOver on iOS currently does not support fieldset and legend for forms. You can address this by using
aria-labelledby="for-attribute-of-label id-of-legend id-of-additional-info"on each input in the fieldset. Using
aria-labelledbywill overwrite the default text read by the screen reader, so it is important to include all relevant information.
- VoiceOver on OS X currently does not support
aria-labelledbyinstead, and include all related fields, including, labels, legend, and hint text