Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

:past — past-element pseudo-class

The :past pseudo-class refers to earlier content on a timeline defined by the document language. In WebVTT, it can be used inside ::cue() to highlight a portion of an active cue once playback reaches the preceding timestamp, or from the start of the cue if there is no preceding timestamp. A match does not mean the portion has finished. It is not a selector for browsing history or dates.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

:past
::cue(:past) { color: lime; }

:past is a pseudo-class without arguments. In Selectors Level 5, it represents elements entirely before a :current element. The document language must define a timeline; without one, the selector matches nothing. Where a timeline exists but the language does not define temporal ordering, previous-sibling order relative to :current applies.

In WebVTT, matching inside ::cue() depends on the playback position and timestamps within the active cue. A timestamp marks when the text after it stops matching :future and starts matching :past. Text before the first timestamp is treated as :past from the start of the cue. A following timestamp is not required for a span to match. Thus, :past does not mean every cue whose start time has elapsed.

The example is a self-contained WebVTT file, but displaying it requires a video and an enabled subtitle track. At 3.000 s, both First and Second are lime in a supporting implementation. First is before the 00:00:02.000 timestamp, and Second is after it. Playback has already passed that timestamp, so both spans match :past.

A definition in a specification draft does not guarantee browser support. Before production use, check actual rendering in the target version; neither the Chromium 152 scope nor syntax acceptance alone establishes that it works.

Examples

WEBVTT

STYLE
::cue { color: white; }
::cue(:past) { color: lime; }

00:00:00.000 --> 00:00:04.000
<c>First</c> <00:00:02.000><c>Second</c>

Result

At playback time 3.000 s: First is lime; Second is lime, in a supporting implementation.

The example output illustrates the expected rendering in a supporting implementation; it does not establish support in any particular browser version.

Sources