JavaScript Element ariaPressed Property

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

What You’ll Learn

Element.ariaPressed is an instance property that reflects the aria-pressed attribute. Learn the true, mixed, false, and undefined values, when to prefer a native button, 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 · mixed · false · undefined

04

Reflects

aria-pressed

05

Status

Baseline widely

06

Used on

Toggle buttons

Introduction

Some buttons fire an action once (Save, Submit). Toggle buttons stay on or off—Bold, Mute, Like, or a toolbar filter. Assistive technologies need to know whether that control is currently pressed.

aria-pressed carries that signal. ariaPressed is the JavaScript reflection of that attribute.

JavaScript
const el = document.getElementById("saveChanges");
console.log(el.ariaPressed); // "false"
el.ariaPressed = "true";
💡
Beginner tip (MDN)

Where possible, use an HTML <button type="button"> (or another element with built-in button semantics). Prefer ARIA toggle buttons when you build a custom control. Keep visuals and keyboard behavior in sync with true / false.

Understanding the Property

MDN: the ariaPressed property of the Element interface reflects the value of the aria-pressed attribute, which indicates the current “pressed” state of toggle buttons.

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

📝 Syntax

JavaScript
ariaPressed

Value

A string with one of the following values:

ValueMeaning (MDN)
"true"The element is pressed.
"false"Supports being pressed but is not currently pressed.
"mixed"Mixed mode value for a tri-state toggle button.
"undefined"The element does not support being pressed.
⚠️
Pressed vs checked

Use ariaPressed on toggle buttons. Use ariaChecked for checkboxes, radios, and similar widgets that have a checked state.

📋 MDN Example Shape

MDN starts with a toggle button marked aria-pressed="false", then updates it to "true" with the property:

JavaScript
<div id="saveChanges" tabindex="0" role="button" aria-pressed="false">Save</div>
JavaScript
let el = document.getElementById("saveChanges");
console.log(el.ariaPressed); // "false"
el.ariaPressed = "true";
console.log(el.ariaPressed); // "true"

Also wire keyboard activation (Space / Enter) and visible pressed styling so the control matches what ariaPressed reports.

⚡ Quick Reference

GoalCode / note
Readel.ariaPressed
Pressel.ariaPressed = "true"
Unpressel.ariaPressed = "false"
Tri-stateel.ariaPressed = "mixed"
Prefer native<button type="button"> when possible
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaPressed.

Kind
get / set

Instance

Type
string

4 tokens

Reflects
aria-pressed

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaPressed. Labs use a custom role="button" toggle so you can safely read and write the property.

📚 Getting Started

Read the reflected value and follow MDN’s toggle update.

Example 1 — Read ariaPressed

Log the current pressed state from a custom toggle button.

JavaScript
const el = document.getElementById("saveChanges");
console.log(el.ariaPressed);

// HTML includes: role="button" aria-pressed="false"
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 "true"

MDN: change from unpressed to pressed.

JavaScript
let el = document.getElementById("saveChanges");
console.log(el.ariaPressed); // "false"
el.ariaPressed = "true";
console.log(el.ariaPressed); // "true"
Try It Yourself

How It Works

Assigning the property updates the reflected aria-pressed attribute so assistive technologies hear the new pressed state.

📈 Mixed, Attribute Sync & Snapshot

Practice tri-state values and verify reflection.

Example 3 — Set "mixed"

Represent a tri-state toggle button.

JavaScript
const el = document.createElement("div");
el.setAttribute("role", "button");
el.setAttribute("aria-pressed", "false");
el.tabIndex = 0;
el.textContent = "Format";
document.body.appendChild(el);

el.ariaPressed = "mixed";
console.log({
  ariaPressed: el.ariaPressed,
  attr: el.getAttribute("aria-pressed")
});
Try It Yourself

How It Works

Use "mixed" only for true tri-state toggles (for example a Format control that is partially applied). Match the visual mixed style too.

Example 4 — Property vs getAttribute

Confirm the attribute stays in sync after a write.

JavaScript
const el = document.createElement("div");
el.setAttribute("role", "button");
el.setAttribute("aria-pressed", "false");
el.textContent = "Save";
document.body.appendChild(el);

el.ariaPressed = "true";
console.log({
  fromProperty: el.ariaPressed,
  fromAttribute: el.getAttribute("aria-pressed"),
  same: el.ariaPressed === el.getAttribute("aria-pressed")
});
Try It Yourself

How It Works

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

Example 5 — Support Snapshot

Feature-detect and list the allowed tokens.

JavaScript
console.log({
  supported: "ariaPressed" in Element.prototype,
  allowed: ["true", "mixed", "false", "undefined"],
  tip: "Prefer native button when possible (MDN)",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Keep visual state, keyboard behavior, and ariaPressed aligned whenever the user toggles the control.

🚀 Common Use Cases

  • Custom toggle buttons built with role="button" and aria-pressed.
  • Toolbar toggles such as Bold, Italic, Mute, or Pin.
  • Tri-state format controls with "mixed".
  • Like / favorite controls that stay pressed when active.
  • Keeping script and markup aligned without manual setAttribute.

🔧 How It Works

1

User activates the toggle

Click, Space, or Enter on a custom toggle button.

Input
2

Script updates ariaPressed

Toggle true / false (or mixed for tri-state).

State
3

Visual UI matches the token

Pressed, unpressed, or mixed styling.

UI
4

Assistive tech announces the state

Screen readers report pressed / not pressed / mixed.

📝 Notes

  • Not Deprecated, Experimental, or Non-standard on MDN (Baseline Widely available).
  • Values are strings: true, mixed, false, undefined.
  • Prefer a native <button type="button"> when possible (MDN).
  • Related: ariaPosInSet, ariaChecked, ariaReadOnly, JavaScript hub.

Browser Support

Element.ariaPressed 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.ariaPressed

String true / mixed / false / undefined — reflects aria-pressed for toggle buttons.

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 ariaPressed IDL — use setAttribute
No
ariaPressed Baseline

Bottom line: Use ariaPressed to get/set aria-pressed on custom toggle buttons. Prefer native buttons when possible. Keep visual state and keyboard behavior in sync with the token you set.

Conclusion

ariaPressed reflects aria-pressed so custom toggle buttons can expose pressed, unpressed, mixed, or unsupported states. Prefer native buttons when you can; when you build a custom toggle, keep the property, visuals, and keyboard behavior aligned.

Continue with ariaReadOnly, ariaPosInSet, ariaChecked, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Prefer native <button type="button"> when possible
  • Use string tokens: true / mixed / false / undefined
  • Sync visuals and keyboard with ariaPressed
  • Use "mixed" only for real tri-state toggles
  • Provide an accessible name on the button text

❌ Don’t

  • Rebuild native buttons with ARIA without need
  • Forget to update the property when the UI toggles
  • Use "mixed" as a fancy pressed style
  • Confuse ariaPressed with ariaChecked
  • Skip focusability (tabindex) on custom widgets

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaPressed

Reflected aria-pressed string for toggle buttons.

5
Core concepts
📝 02

Four values

true mixed false undefined

Tokens
🔍 03

Toggle buttons

role=button

Use
04

Baseline

widely available

Status
🎯 05

Prefer native

button element

Rule

❓ Frequently Asked Questions

It reflects the aria-pressed attribute as a string, indicating the current pressed state of toggle buttons.
No. MDN marks Element.ariaPressed as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
One of the strings "true", "mixed", "false", or "undefined".
Yes when possible. MDN recommends an HTML element with type="button" (or a button element) because it has built-in semantics and does not require ARIA attributes.
A mixed mode value for a tri-state toggle button — neither fully pressed nor unpressed.
ariaPressed is for toggle buttons (pressed/unpressed). ariaChecked is for checkboxes, radios, and similar widgets that have a checked state.
Did you know?

The string "undefined" is a real ARIA token meaning “does not support being pressed”—it is not the same as JavaScript’s undefined value when the attribute is missing. A normal action button (Save once) usually needs no aria-pressed at all.

Next: ariaReadOnly

Learn the reflected aria-readonly property for non-editable but operable widgets.

ariaReadOnly →

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