The onpause attribute is an event-handler attribute for <audio> and <video>. It runs JavaScript when the pause event fires — playback has entered the paused state (usually after pause() or the user presses Pause in controls).
The event fires once pause() returns and after the media element’s paused property is true. It is not cancelable and does not bubble. Pair it with onplay to keep custom UI in sync.
Baseline · Widely available.
Not deprecated and not experimental. The pause event is stable across modern browsers since about July 2015.
Prefer addEventListener in apps.
Inline onpause is fine for learning. Production code usually uses media.addEventListener("pause", handler). Pausing because of buffering uses waiting, not pause.
Syntax
HTML Syntax
syntax.html
<video|audio onpause="script">
script is JavaScript that runs when pause fires. Equivalent JS: media.onpause = handler or media.addEventListener("pause", handler).
Values
Attribute Values
The attribute value is always a script. Common patterns:
Same player, two events — cleaner than polling paused.
Ending the media often pauses too — also see onended.
Edge Cases & Pitfalls
Most mistakes are confusing buffering stalls with pause, or expecting the event to bubble.
vs waiting
Buffering is not pause
When playback stops for data, you get waiting. pause means the element entered the paused state (user or pause()).
bubble
Does not bubble
Listen on the audio/video element itself. Parent listeners will not see a bubbling pause.
ended
End of media
Reaching the end can also leave the media paused. Use onended when you care specifically about completion.
already
Calling pause() when already paused
If paused is already true, another pause() typically does not fire pause again.
property
.onpause = replaces listeners
Assigning the IDL property overwrites a previous assignment. Prefer addEventListener for multiple handlers.
Compatibility
Browser Support
onpause 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
onpause
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support the pause event on audio and video.
97%Global support (approx.)
Google Chrome3+
Full support
Mozilla Firefox3.5+
Full support
Apple Safari3.1+
Full support
Microsoft Edge12+
Full support
Opera10.5+
Full support
Samsung InternetModern · Full
Full support
Internet Explorer9+
Supported
onpauseWidely supported
Bottom line: Safe to use for media UI sync. Prefer addEventListener in production, and use waiting/ended for buffering and completion.
Remember
Key Takeaways
Role: run script when audio/video enters the paused state.
Trigger: user Pause or pause() — then paused === true.
Pair with:onplay (and often onended).
Not buffering: use waiting for stalls, not pause.
One line:onpause means the media is paused — sync your UI, and don’t confuse it with buffering.
Frequently Asked Questions
It is an event-handler attribute on audio or video. When playback enters the paused state — usually after pause() or the user presses Pause — the pause event fires and the JavaScript in onpause runs.
The HTML audio and video elements. Put the handler on the media element itself.
After the pause request is handled and the media element’s paused property is true — typically once pause() returns. The event is not cancelable and does not bubble.
onplay runs when playback is requested to start (paused becomes false). onpause runs when playback is paused (paused becomes true). Pair them to keep UI in sync.
Both work. For learning, onpause in HTML is fine. In production code, prefer media.addEventListener("pause", handler).
No. The pause event and onpause handler are standard HTML media features and Baseline widely available since about July 2015.