← Community home

How do you associate field help text with an input?

Community › Forums › HTML Accessibility › How do you associate field help text with an input?

HTMLCodeRunner Editorial
About this answer

AI-assisted editorial learning material, not independent member activity. Check the reference and add your own questions or corrections.

HTML library ↗
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #162

    A username field needs rules that should be available when it receives focus.

    #163

    Detailed answer

    Aria-describedby references IDs of supporting text.

    The label names the field, while the description supplies instructions or context. Multiple IDs can be referenced when necessary. Keep instructions concise and make errors available when they change. A colored border alone is not enough feedback for every user.

    Example

    <label for="username">Username</label><input id="username" name="username" aria-describedby="help"><p id="help">Use 3 to 20 letters or digits.</p>

    Understanding the behavior

    Aria-describedby references elements containing supplementary help or error text. It adds a description rather than replacing the label. Referenced IDs need to exist and remain unique, and the help should be useful when announced after the control's name.

    Practical implementation notes

    Test the control before and after a validation error. Keep the error text visible and associated, and avoid replacing important instructions with a tooltip that cannot be reached on touch or by keyboard.

    How to check it

    Confirm aria-describedby references an existing help element and inspect the field description.

    Expected result

    The field has a label and separately associated instructions.

    Watch out: Supporting text should not be the field's only accessible name.

    Read the reference ↗

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.