HTML & CSS · Senior · Question 67 of 75

How do you correctly associate an error message with an input?

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

Explanation

Screen readers then read the error when the field is focused. Color alone fails WCAG for users who can't distinguish it.

Further reading

Problem with a question

HTML & CSS · Senior · question 67

Test yourself

Take the HTML & CSS · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz