Imagine asking a friend for some information on a webpage. The field should explain exactly what you need.
What You Need to Know
The help paragraph has its own ID. aria-describedby connects that text to the input for assistive technology.
Try the Example
Take a look at the example. We’ll explain the important lines right below it.
<label for="nickname">Nickname</label>
<input id="nickname" name="nickname" aria-describedby="nickname-help">
<p id="nickname-help">Use 4 to 20 characters; do not include your email address.</p>
Let’s Read the Code
- <label>: The label tells people what the input is for. A matching for/id pair makes the label clickable.
- <input>: The input is a control. Its type changes the way people enter information.
- for: For connects a label or output with a control by ID.
- id: An id uniquely identifies an element on this page.
Read the named elements and attributes together. They explain how the browser connects this feature to the rest of the page.
What Happens in the Browser?
The HTML controls work in the browser, but saving an answer requires the example action path to be handled by a real server.
Where does the answer go? The example uses the submitted name(s) nickname. Those names help the receiving server identify each answer. A label is for people; a name attribute is for the form data; an ID connects elements in the page.
Your Turn
Change the help text and verify that the aria-describedby value still references its ID.
Common Beginner Mistakes
- Copying the example without giving the fields a clear label and a usable name.
- The help text must be visible when people need it; an ARIA relationship alone does not show instructions.
Key Takeaways
- Choose the HTML feature that explains this task clearly.
- <label>: The label tells people what the input is for. A matching for/id pair makes the label clickable.
- A meaningful HTML element is usually a stronger starting point than adding an ARIA role to a generic div. Also check what happens using only the keyboard.