Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Pseudo-classes

The :playing pseudo-class

Reference for the CSS :playing pseudo-class: match audio and video elements that are playing. Limited browser support, with a JavaScript fallback.

The :playing pseudo-class matches an <audio> or <video> element that is currently playing. It belongs to the "resource state" pseudo-classes of the Selectors Level 4 family, together with :paused.

Support is limited: not all browsers know :playing, and a rule using an unknown selector is dropped entirely. Always keep a JavaScript or class-based fallback for anything that matters.

CSS
video:playing {
  outline: 3px solid seagreen;
}

Try it

Playing outline with a fallback

Syntax

CSS
:playing { /* declarations */ }

No arguments; specificity (0,1,0).

Syntax and arguments

Part Description
:playing Matches a media element whose playback is in progress.
:not(:playing) Matches paused, ended or not-yet-started media. Also matches elements that are not media at all.

Usage notes

  • Check support first. Use @supports selector(:playing) { ... } to wrap rules, or detect with CSS.supports("selector(:playing)") in script.
  • Fallback with events. The media play and pause events (plus ended) are widely supported and let you set a class that works everywhere.
  • Buffering still counts. The spec treats an element that wants to play but is waiting for data as playing in some states; do not use it as a precise "audio is audible" signal.
  • Muted or hidden media still plays. The match depends on playback state, not volume or visibility.
  • Keep native controls accessible. If you hide the default controls to show a custom look, provide keyboard-accessible buttons.

Browser support

Limited: available in only some browsers and not Baseline. Verify on a current support table and provide a fallback.