JavaScript Element ariaErrorMessageElements Property
Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline 2025
Instance property
Overview
What You’ll Learn
Element.ariaErrorMessageElements is an instance property that holds an array of elements providing an error message. Learn how it relates to aria-errormessage, how to pair it with ariaInvalid, and how to get or set the relationship from JavaScript—with five examples and try-it labs.
01
Kind
Instance property
02
Returns
HTMLElement[]
03
Writable
Yes (get / set)
04
Reflects
aria-errormessage
05
Status
Baseline 2025
06
Pairs with
ariaInvalid
Fundamentals
Introduction
Form fields need a clear place for error text: “Enter a valid email address,” “Password is required,” and so on. ARIA links a control to that message with aria-errormessage.
ariaErrorMessageElements is the modern element-reference form: you work with real DOM nodes instead of only managing id strings. Pair it with ariaInvalid so the error is announced and styled when the field is invalid.
Point the field at the error message element(s), then set ariaInvalid = "true" when validation fails and "false" when it passes. CSS can show or hide the message with [aria-invalid="true"].
Concept
Understanding the Property
MDN: the ariaErrorMessageElements property of the Element interface is an array containing the element (or elements) that provide an error message for the element it is applied to.
Get / set — read or assign an array of elements.
Flexible alternative to the aria-errormessage attribute.
No id required on message nodes when you set the property (MDN).
Reflection — reads valid in-scope id refs from the attribute; setting the property clears the attribute.
Foundation
📝 Syntax
JavaScript
ariaErrorMessageElements
Value
An array of subclasses of HTMLElement. The inner text of these elements can be joined with spaces to get the error message.
When read, the returned array is static and read-only.
When written, the assigned array is copied—later edits to that array do not change the property.
Compare
⚖️ Property vs aria-errormessage Attribute
Attribute
Property
API
aria-errormessage="err1"
el.ariaErrorMessageElements
Points to
Space-separated id strings
Array of Element objects
Targets need id?
Yes
No (when set via property)
After you set the property
—
Corresponding attribute is cleared (MDN)
Pattern
📋 Email Input With Error (MDN Shape)
MDN links an email field to an error span via aria-errormessage, then toggles ariaInvalid from Constraint Validation:
JavaScript
<p>
<label for="email">Email address:</label>
<input type="email" name="email" id="email" aria-errormessage="err1" />
<span id="err1" class="errormessage">Error: Enter a valid email address</span>
</p>
Detect support and read MDN’s email error-message example.
Example 1 — Feature-Detect
Check whether the reflected property exists.
JavaScript
if ("ariaErrorMessageElements" in Element.prototype) {
console.log("ariaErrorMessageElements is supported");
} else {
console.log("ariaErrorMessageElements not supported by browser");
}
Element.ariaErrorMessageElements is Baseline Newly available (MDN: across latest browsers since April 2025). Feature-detect on older engines and keep an aria-errormessage id fallback if needed. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline 2025
Element.ariaErrorMessageElements
HTMLElement[] — reflected aria-errormessage element references.
BaselineNewly available 2025
Google ChromeSupported in current releases — feature-detect older
Yes
Microsoft EdgeSupported in current releases — feature-detect older
Yes
Mozilla FirefoxSupported in current releases — feature-detect older
Yes
Apple SafariSupported in current releases — feature-detect older
Yes
OperaFollow Chromium support
Yes
Internet ExplorerNot supported — use aria-errormessage attribute
No
ariaErrorMessageElementsBaseline
Bottom line: Detect "ariaErrorMessageElements" in Element.prototype. Prefer element arrays for dynamic error text. Pair with ariaInvalid. Fall back to aria-errormessage id strings when the property is missing.
Wrap Up
Conclusion
ariaErrorMessageElements lets you associate error message elements with a control using real Element references. Feature-detect on older browsers, pair with ariaInvalid, and re-assign the array when message nodes change.
Mutate a previously assigned array and expect updates
Assume every older browser exposes the IDL property
Leave ariaInvalid true after the field is fixed
Point to empty or unrelated elements
Confuse this with a general description (aria-describedby)
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about ariaErrorMessageElements
Reflected aria-errormessage as an array of element references.
5
Core concepts
📄01
Get / set
on Element
Kind
📝02
Element array
HTMLElement[]
Type
🔍03
No id needed
when property-set
Rule
✅04
Baseline
newly available
Status
🎯05
ariaInvalid
show when invalid
Pair
❓ Frequently Asked Questions
An array of HTMLElement subclasses that provide an error message for the element. Join their inner text with spaces to form the error message string.
No. MDN marks Element.ariaErrorMessageElements as Baseline 2025 (newly available since April 2025). It is not Deprecated, Experimental, or Non-standard. Feature-detect on older browsers.
The attribute uses space-separated id strings. The property uses Element references. Assigned elements do not need an id. Setting the property clears the corresponding attribute.
Wire the error message elements with ariaErrorMessageElements (or aria-errormessage), then set ariaInvalid to true when the field is invalid so assistive technologies and CSS can show the error.
No. When read, the returned array is static and read-only. When written, the assigned array is copied—later changes to that array do not update the property.
Yes. Custom elements can use ElementInternals.ariaErrorMessageElements for the same relationship from inside a component.
Did you know?
An error message association is most useful when the field is marked invalid. MDN’s email demo uses Constraint Validation’s typeMismatch to drive ariaInvalid, which in turn reveals the linked error text.