JavaScript Element ariaModal Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

In JavaScript, ariaModal reflects the aria-modal attribute: a string ("true" / "false") that tells assistive technology whether a dialog is modal when displayed (MDN).

Read the notes below before you get or set this property. Prefer feature detection when support is limited.

Syntax

Use el.ariaModal. Start with this line.

JavaScript
element.ariaModal
CallWhat it does
element.ariaModalPrimary signature.

Built into the browser. Read or assign el.ariaModal — no import required.

Library declarations
JavaScript
element.ariaModal

Parameters

ParameterDescription
ValueOptional. "true" or "false"
Focus managementRequired. Trap inside; restore on close
Custom elementsOptional. ElementInternals.ariaModal

Return Value

Return ValueDescription
*The current value of el.ariaModal.

JavaScript Examples

Example 1 — Get and Set (MDN)

Read the current modality, then set it to "false".

JavaScript
let el = document.getElementById("address-modal");
console.log(el.ariaModal); // "true"
el.ariaModal = "false";
console.log(el.ariaModal); // "false"
Try It Yourself

How It Works

  1. Select the dialog. It already has aria-modal="true".
  2. Read ariaModal. Returns the string "true".
  3. Assign "false". Updates the reflected attribute.
  4. Read again. Confirms the dialog is no longer marked modal.

Example 2 — role="dialog" + Modal

Declare a dialog and mark it modal for assistive technology.

JavaScript
const box = document.getElementById("confirm");
box.setAttribute("role", "dialog");
box.ariaModal = "true";
box.setAttribute("aria-labelledby", "confirm-title");
console.log(box.role, box.ariaModal);
Try It Yourself

How It Works

  1. Set the role. dialog identifies the container.
  2. Set ariaModal. Tells AT outside content is inert while open.
  3. Name the dialog. Use aria-labelledby (or similar) for an accessible name.
  4. Add real modal behavior (focus / inert) separately in your app.

Example 3 — Property Reflects the Attribute

Show that ariaModal and aria-modal stay in sync.

JavaScript
const el = document.getElementById("address-modal");
el.ariaModal = "false";
console.log(el.getAttribute("aria-modal")); // "false"
el.setAttribute("aria-modal", "true");
console.log(el.ariaModal); // "true"
Try It Yourself

How It Works

  1. Write via the property. Attribute updates immediately.
  2. Read via getAttribute. Same value as ariaModal.
  3. Write via the attribute. Property reflects the change.
  4. Use string tokens. "true" and "false" (not booleans alone as the attribute form).

Browser Support

Element.ariaModal is marked Baseline Widely available on MDN (since October 2023). Logos use the shared browser-image-sprite.png sprite from this project.

✓ Baseline · Widely available

Element ariaModal

Reflects aria-modal — whether a dialog is modal when displayed.

Widely Available
Google Chrome Full support · Desktop & Mobile
Full support
Mozilla Firefox Full support · Desktop & Mobile
Full support
Apple Safari Full support · macOS & iOS
Full support
Microsoft Edge Full support · Chromium
Full support
Opera Full support · Modern versions
Full support
Internet Explorer No Element.ariaModal
Not supported
ariaModal Baseline support

Bottom line: Safe in modern browsers. Pair with focus management (or native dialog showModal). See the MDN Element.ariaModal reference.

Frequently Asked Questions

It reflects the aria-modal attribute as a string, indicating whether an element is modal when displayed—so assistive technologies treat content outside the dialog as inert.
No. MDN marks Element.ariaModal as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
The strings "true" (the element is modal) or "false" (the element is not modal).
MDN: applying aria-modal on an element with role="dialog" replaces the older technique of using aria-hidden on the background to tell AT that outside content is inert.
No. It is an accessibility signal. You still need keyboard focus management (and often inert/backdrop behavior) for a complete modal experience—or use the native HTML dialog with showModal().
Yes. Reading and writing ariaModal updates the reflected aria-modal attribute.

Next: Element ariaMultiLine

Learn how textboxes expose multi-line semantics to assistive technology.

ariaMultiLine tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful