How do I connect form instructions and error explanations to a field?
Quick answer
Give the input a clear visible label. Put its instruction and any error explanation in elements with IDs, then reference the relevant IDs in the input’s aria-describedby attribute. When the value is invalid, aria-invalid="true" can indicate that state. Keep the messages specific: say what information is expected, and, for an error, what went wrong and how to fix it. [S1] [S2]
The question, the details, the next step.
A practical checklist
Give the input a clear visible label.
State the actual expected format or constraint in the instruction.
Use IDs for descriptive text and reference the relevant IDs in
aria-describedby.Make each error explain what went wrong and how to fix it.
Check that referenced IDs exist and describe the intended field; reflect the field’s actual state.
A few more useful answers
Can `aria-describedby` reference both instructions and an error?
It can identify one or more descriptive elements by ID. Reference the descriptions that apply to the field’s current state. [S1]
Does `aria-describedby` replace a visible field label?
No. Keep a clear label; the guidance recommends labeling every input field. [S2]
Does this example specify a complete validation implementation?
No. It illustrates associating descriptive text and indicating an invalid value. It does not specify every validation behavior. [S1]
Sources
References used for this guide.
- [S1] Accessibility in forms, products, and controls learn.microsoft.com · Checked
- [S2] Write accessible documentation developers.google.com · Checked
