HTML: aria-describedby

The aria-describedby attribute connects a control to supplementary text such as instructions, hints, or an error message.

What you will learn

Minimal example

<label for="password">Password</label>
<input id="password" aria-describedby="password-help" type="password">
<p id="password-help">Use at least 12 characters.</p>

The input keeps its name from the visible label. The text in password-help is additional information that assistive technology can announce.

Error message example

<input id="email" aria-describedby="email-error" aria-invalid="true">
<p id="email-error">Enter a valid email address.</p>

The referenced element must have a matching unique id. Keep the help or error text visible when sighted users also need it.

Common mistakes