The onvolumechange attribute is an event-handler attribute for <audio> and <video>. It runs JavaScript when the volumechange event fires — either the volume property or the muted property changed.
Use it to sync a custom volume UI, show a mute icon, or log level changes. Related: muted, controls, onplay, and onpause.
Baseline · Widely available.
Not deprecated and not experimental. Per MDN, volumechange is not cancelable and does not bubble. Stable since about July 2015.
Discouraged as inline HTML.
MDN discourages HTML event handler attributes. Prefer media.addEventListener("volumechange", handler) in production; use inline onvolumechange for quick demos and learning.
Syntax
HTML Syntax
syntax.html
<video|audio onvolumechange="script">
script is JavaScript that runs when volume or mute changes. Equivalent JS: media.onvolumechange = handler or media.addEventListener("volumechange", handler).
Values
Attribute Values
The attribute value is always a script. Common patterns:
volumechange fires for mute changes too (per MDN).
Update UI from clip.muted in one place.
Note: mute does not reset volume — the previous level returns when unmuted.
Edge Cases & Pitfalls
Most confusion is treating mute as “volume = 0” instead of a separate muted flag.
mute
Mute ≠ volume 0
muted silences playback while keeping the last volume value. Always check both properties in your handler.
range
volume is 0.0–1.0
Not 0–100. Divide percent sliders by 100 when assigning media.volume.
api
Not cancelable
You cannot stop volumechange with preventDefault(). React after it fires.
target
Listen on audio/video
The event targets the media element. Nested <source> tags do not receive onvolumechange.
os
System volume is separate
OS / device master volume usually does not fire this event — only the element’s volume / muted.
Compatibility
Browser Support
onvolumechange is an HTML event-handler attribute for media elements in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
onvolumechange
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support volumechange on audio and video.
97%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetModern
Full support
Internet Explorer9+
Supported
onvolumechangeWidely supported
Bottom line: Safe to use for custom volume/mute UI. Prefer addEventListener('volumechange') in apps, and always read both volume and muted.
Remember
Key Takeaways
Role: media volume or muted changed.
Not cancelable and does not bubble.
volume is 0.0–1.0; mute is a separate boolean.
One handler covers both slider and mute changes.
One line:onvolumechange means the media got louder, quieter, or muted — read volume and muted.
Frequently Asked Questions
It is an event-handler attribute on audio or video. When the volume property or the muted property changes, the volumechange event fires and the JavaScript in onvolumechange runs.
HTML audio and video elements. Put the handler on the media element itself, not on nested source tags.
Yes. Per MDN, volumechange fires when either volume or muted changes — so one handler covers both the volume slider and mute.
A number from 0.0 (silent) to 1.0 (loudest). Setting it in script or via the browser controls fires volumechange.
No. Per MDN, volumechange is not cancelable and does not bubble.
No. The volumechange event and onvolumechange handler are standard HTML media features and Baseline widely available since about July 2015. Inline HTML handlers are discouraged in production in favor of addEventListener.