0Pricing
Web Accessibility Academy · Lesson

Tying Errors to Fields With aria-describedby

Make the message read with its input.

Tying Errors to Fields With aria-describedby is a free Web Accessibility Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Web Accessibility Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

A Floating Error

An error message sitting near a field looks connected to you. But to a screen reader it is just loose text the user may never hear. ⚠️

The Fix Is a Link

You need to formally tie the message to its input. The attribute that does this is aria-describedby, and it lives on the field.

Point to an id

Give the error element an id, then set the input's aria-describedby to that same id. Now the two are officially linked.

<input id="email" aria-describedby="email-err">
<p id="email-err">Enter a valid email.</p>

What the User Hears

When focus lands on the input, the screen reader reads the label, the type, and then the description. The error is no longer orphaned.

Name Then Description

aria-describedby does not replace the label. The label gives the name; describedby adds extra info that is read after it.

Multiple Descriptions

You can list several ids, space-separated. The browser reads them in order, so you can join a hint and an error together.

<input aria-describedby="hint err">

Only When It Applies

Add the error id to aria-describedby only while the error is showing. Pointing at an empty or hidden node can read nothing or confuse users.

Keep the Text Real

The described element must hold real, visible text. aria-describedby reads its content, so an empty span describes nothing useful.

Hidden Targets Stay Silent

If the target has display none, most screen readers skip it. Keep error text rendered and visible so the description is actually announced.

Works With aria-invalid

Pair describedby with aria-invalid on the same field. One says this failed; the other says here is why. Together they tell the full story.

Not Just for Errors

The same attribute carries format hints too, like password rules. Errors are one common use, not the only one.

<input aria-describedby="pw-rule">
<p id="pw-rule">At least 8 characters.</p>

Quick Check

How do you make a screen reader read an error with its field?

Recap

Tie errors to fields with aria-describedby pointing at a real, visible id. The screen reader then reads the field and its error together. ✅

Frequently asked questions

Is the “Tying Errors to Fields With aria-describedby” lesson free?

Yes — the full text of “Tying Errors to Fields With aria-describedby” is free to read here on the web, and the Web Accessibility Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Web Accessibility Academy course, upgrade to CoddyKit PRO.

What will I learn in “Tying Errors to Fields With aria-describedby”?

Make the message read with its input. You practise Web Accessibility Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Web Accessibility Academy?

No prior experience is required. Web Accessibility Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Tying Errors to Fields With aria-describedby” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Web Accessibility Academy lesson?

Yes. Every Web Accessibility Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Tying Errors to Fields With aria-describedby
  2. Marking Invalid State With aria-invalid
  3. Moving Focus to the First Error
  4. Inline, On-Blur, or On-Submit: Timing Matters
← Back to Web Accessibility Academy