Inline error method 2: The aria-describedby attribute

Home | Full results | Github page

In some cases, it is not possible to wrap the label around the form control or error message. The aria-describedby can be used to explicitly associate the error message with the form control using matching aria-describedby and id values.

Example

Error: Must be a valid phone number

Markup

<div class="form-container">
  <label class="form-label" for="error2">Phone number</label>
  <input class="form-input form-input--error" id="error2" type="text" aria-describedby="described1">
  <span class="error" id="described1">Error: Must be a valid phone number</span>
</div>

Results

OSX Voiceover Windows NVDA Windows JAWS
Chrome Safari Opera Chrome Firefox Edge Chrome Firefox Edge
PASS PASS PASS PASS PASS PASS PASS PASS FAIL

Home | Full results | Github page