Element: ariaErrorMessageElements property

Baseline 2025
Newly available

Since April 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

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.

The aria-errormessage topic contains additional information about how the attribute and property should be used.

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 a static and read-only. When written, the assigned array is copied: subsequent changes to the array do not affect the value of the property.

Description

The property is a flexible alternative to using the aria-errormessage attribute to set the error message for an element. Unlike aria-errormessage, the elements assigned to this property do not have to have an id attribute.

The property reflects the element's aria-errormessage attribute when it is defined, but only for listed reference id values that match valid in-scope elements. If the property is set, then the corresponding attribute is cleared. For more information about reflected element references and scope see Reflected element references in the Reflected attributes guide.

Examples

Email input with error message

This example shows how we use the aria-errormessage to set the error message for reporting entry of an invalid email address, and demonstrates how we can get and set the message using ariaErrorMessageElements.

HTML

First we define an HTML email input, setting its aria-errormessage attribute to reference an element with the id of err1. We then define a <span> element that has this id, and which contains an error message.

html

CSS

We create some styles to hide the error message by default, but make it visible and styled as an error when aria-invalid is set on the element.

css

JavaScript

We then check for input, and set ariaInvalid to true or false based on the typeMismatch constraint violation. ariaInvalid is in turn reflected in the aria-invalid attribute, which hides and displays the error as needed.

js

We then log the value of the aria-errormessage attribute, the ariaErrorMessageElements and the inner text of the ariaErrorMessageElements

js

Result

As you enter an email address, the error text will be displayed until the email address is valid. Note that the log shows the error message reference read from the attribute, the element from ariaErrorMessageElements, and the inner text of the element, which is its error message.

Specifications

Specification
Accessible Rich Internet Applications (WAI-ARIA)
# dom-ariamixin-ariaerrormessageelements

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
ariaErrorMessageElements
Chrome – Full support
Chrome 135 (Release date: 2025-04-01)
footnote Full support
Edge – Full support
Edge 135 (Release date: 2025-04-04)
footnote Full support
Firefox – Full support
Firefox 136 (Release date: 2025-03-04)
footnote Full support
Opera – Full support
Opera 120 (Release date: 2025-07-02)
footnote Full support
Safari – Full support
Safari 16.4 (Release date: 2023-03-27)
footnote Full support
Chrome Android – Full support
Chrome Android 135 (Release date: 2025-04-01)
footnote Full support
Firefox for Android – Full support
Firefox for Android 136 (Release date: 2025-03-04)
footnote Full support
Opera Android – Full support
Opera Android 89 (Release date: 2025-04-29)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16.4 (Release date: 2023-03-27)
footnote Full support
Samsung Internet – Full support
Samsung Internet 29 (Release date: 2025-10-25)
footnote Full support
WebView Android – Full support
WebView Android 135 (Release date: 2025-04-01)
footnote Full support
WebView on iOS – Full support
WebView on iOS 16.4 (Release date: 2023-03-27)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also