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
Fundamentals
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.
Concept
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 tokens — true, mixed, false, undefined.
Baseline — widely available since October 2023 (MDN).
Foundation
📝 Syntax
JavaScript
ariaPressed
Value
A string with one of the following values:
Value
Meaning (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.
Pattern
📋 MDN Example Shape
MDN starts with a toggle button marked aria-pressed="false", then updates it to "true" with the property:
Element.ariaPressed is Baseline Widely available (MDN: across browsers since October 2023). Logos use the shared browser-image-sprite.png sprite from this project.
Internet ExplorerNo ariaPressed IDL — use setAttribute
No
ariaPressedBaseline
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.
Wrap Up
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.
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about ariaPressed
Reflected aria-pressed string for toggle buttons.
5
Core concepts
📄01
Get / set
on Element
Kind
📝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.