JavaScript Element ariaModal Property

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline
Instance property

What You’ll Learn

Element.ariaModal is an instance property that reflects the aria-modal attribute. Learn the true and false tokens, how modal dialogs signal that outside content is inert, and how to get or set the property from JavaScript—with five examples and try-it labs.

01

Kind

Instance property

02

Type

String

03

Values

true · false

04

Reflects

aria-modal

05

Status

Baseline widely

06

Common with

role="dialog"

Introduction

A modal dialog asks the user to finish something before returning to the page: confirm a delete, pick an address, complete a form. Sighted users see a backdrop. Assistive technologies need an explicit signal that the dialog is modal.

aria-modal carries that signal. ariaModal is the JavaScript reflection of that attribute.

JavaScript
const el = document.getElementById("address-modal");
console.log(el.ariaModal); // "true"
el.ariaModal = "false";
💡
Beginner tip (MDN)

On an element with role="dialog", aria-modal="true" replaces the older technique of setting aria-hidden on the background to tell AT that outside content is inert. You still need focus management (or a native <dialog> with showModal()) for a complete modal UX.

Understanding the Property

MDN: the ariaModal property of the Element interface reflects the value of the aria-modal attribute, which indicates whether an element is modal when displayed.

  • Reflected attribute — mirrors aria-modal.
  • Get / set — readable and writable string.
  • Two tokenstrue, false.
  • Baseline — widely available since October 2023 (MDN).

📝 Syntax

JavaScript
ariaModal

Value

A string with one of the following values:

ValueMeaning (MDN)
"true"The element is modal.
"false"The element is not modal.
⚠️
Signal vs behavior

ariaModal informs assistive technologies. Trap focus, handle Escape, and inert the background (or use native modal dialog APIs) so keyboard users get the same modality sighted users expect.

📋 MDN Example Shape

MDN starts with aria-modal="true" on a dialog, then updates it to "false":

JavaScript
<div
  role="dialog"
  id="address-modal"
  aria-labelledby="dialog1Title"
  aria-describedby="dialog1Desc"
  aria-modal="true"
></div>
JavaScript
let el = document.getElementById("address-modal");
console.log(el.ariaModal); // "true"
el.ariaModal = "false";
console.log(el.ariaModal); // "false"

Related naming APIs for dialogs: ariaLabelledByElements and ariaDescribedByElements.

⚡ Quick Reference

GoalCode / note
Readel.ariaModal
Mark modalel.ariaModal = "true"
Mark non-modalel.ariaModal = "false"
Typical rolerole="dialog" (or alertdialog)
Native alternative<dialog> + showModal()
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaModal.

Kind
get / set

Instance

Type
string

true / false

Reflects
aria-modal

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaModal. Labs use a dialog-style control so you can safely read and write the property.

📚 Getting Started

Read the reflected value and follow MDN’s update.

Example 1 — Read ariaModal

Log whether a dialog is marked modal.

JavaScript
const el = document.getElementById("address-modal");
console.log(el.ariaModal);

// HTML includes: role="dialog" aria-modal="true"
Try It Yourself

How It Works

The property returns the attribute string. If the attribute is missing, many browsers return null.

Example 2 — MDN Update to "false"

MDN: clear modality on the dialog.

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

Assigning the property updates the reflected aria-modal attribute so assistive technologies know whether outside content should be treated as inert.

📈 Open Modal Dialog, Attribute Sync & Snapshot

Practice marking dialogs modal and verify reflection.

Example 3 — Set "true" on a Dialog

Create a dialog and mark it modal.

JavaScript
const dialog = document.createElement("div");
dialog.setAttribute("role", "dialog");
dialog.setAttribute("aria-label", "Confirm delete");
dialog.textContent = "Are you sure?";
document.body.appendChild(dialog);

dialog.ariaModal = "true";
console.log({
  ariaModal: dialog.ariaModal,
  attr: dialog.getAttribute("aria-modal")
});
Try It Yourself

How It Works

Pair role="dialog" with a clear accessible name (aria-label or labelled-by) whenever you open a modal.

Example 4 — Property vs getAttribute

Confirm the attribute stays in sync after a write.

JavaScript
const el = document.createElement("div");
el.setAttribute("role", "dialog");
el.setAttribute("aria-modal", "true");
el.setAttribute("aria-label", "Address");
document.body.appendChild(el);

el.ariaModal = "false";
console.log({
  fromProperty: el.ariaModal,
  fromAttribute: el.getAttribute("aria-modal"),
  same: el.ariaModal === el.getAttribute("aria-modal")
});
Try It Yourself

How It Works

Prefer ariaModal in script; keep the attribute for HTML markup.

Example 5 — Support Snapshot

Feature-detect and remember the dialog pairing.

JavaScript
console.log({
  supported: "ariaModal" in Element.prototype,
  allowed: ["true", "false"],
  tip: "Use with role=dialog; still manage focus / inert yourself",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Consider the HTML <dialog> element when you want built-in modal behavior plus a clear accessibility story.

🚀 Common Use Cases

  • Confirm / alert dialogs that block the rest of the page.
  • Custom address or settings modals with role="dialog".
  • Toggling modality when a panel switches between modal and non-modal modes.
  • Replacing background aria-hidden patterns with aria-modal (MDN).
  • Keeping script and markup aligned without manual setAttribute.

🔧 How It Works

1

Open a dialog

Usually role="dialog" with a clear name.

UI
2

Set ariaModal to true

Tell AT the dialog is modal when displayed.

Signal
3

Manage focus and backdrop

Trap focus, handle Escape, inert outside content.

Behavior
4

Users stay inside the dialog

AT and keyboard UX both treat outside content as inert.

📝 Notes

  • Not Deprecated, Experimental, or Non-standard on MDN (Baseline Widely available).
  • On role="dialog", prefers aria-modal over background aria-hidden (MDN).
  • Does not by itself trap focus or block pointer events.
  • Related: ariaMultiLine, ariaHidden, EventTarget, JavaScript hub.

Browser Support

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

Baseline Widely available

Element.ariaModal

String true / false — reflects aria-modal for whether a displayed element is modal.

Baseline Widely available
Google Chrome Supported (ARIA reflection)
Yes
Microsoft Edge Supported (ARIA reflection)
Yes
Mozilla Firefox Supported (ARIA reflection)
Yes
Apple Safari Supported (ARIA reflection)
Yes
Opera Follow Chromium support
Yes
Internet Explorer No ariaModal IDL — use setAttribute
No
ariaModal Baseline

Bottom line: Use ariaModal on dialogs to declare modality for assistive technologies. Pair with focus management (or native dialog showModal). Prefer aria-modal over hiding the whole background with aria-hidden.

Conclusion

ariaModal reflects aria-modal so dialogs can declare whether they are modal. Use it with role="dialog", keep an accessible name, and still implement focus and backdrop behavior—or lean on native <dialog> when it fits.

Continue with ariaMultiLine, ariaHidden, EventTarget, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Set ariaModal = "true" on modal dialogs
  • Provide a clear dialog name (labelled-by / label)
  • Trap focus and support Escape
  • Prefer aria-modal over background aria-hidden
  • Consider native <dialog>.showModal()

❌ Don’t

  • Assume the property alone blocks keyboard access outside
  • Open unnamed dialogs
  • Leave focus behind the backdrop
  • Mark non-modal panels as modal
  • Forget to restore focus when the dialog closes

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaModal

Reflected aria-modal string for dialog modality.

5
Core concepts
📝 02

true / false

modal or not

Values
🔍 03

dialog role

common pairing

Use
04

Baseline

widely available

Status
🎯 05

Still manage focus

signal ≠ trap

Rule

❓ 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.
Did you know?

The native HTML <dialog> element with showModal() creates a top-layer modal with built-in focus behavior. Custom dialogs still benefit from ariaModal = "true" so AT knows the intent matches that pattern.

Next: Element ariaMultiLine

Learn the reflected aria-multiline property for single-line vs multi-line text boxes.

ariaMultiLine →

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.

5 people found this page helpful