{"id":334774,"date":"2021-02-23T09:58:34","date_gmt":"2021-02-23T17:58:34","guid":{"rendered":"https:\/\/css-tricks.com\/?page_id=334774"},"modified":"2021-02-23T10:01:55","modified_gmt":"2021-02-23T18:01:55","slug":"past","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/selectors\/p\/past\/","title":{"rendered":":past"},"content":{"rendered":"\n

:past<\/code> is a CSS pseudo-selector that matches elements that have passed along a timeline. Where you’ll see this come into play is largely with video subtitles created with WebVTT. When a subtitle is no longer the currently displayed text, it becomes a part of the past as far as the timeline is concerned, and :past<\/code> allows us to match and style it accordingly.<\/p>\n\n\n\n\n\n\n\n

:past(p) {\n  opacity: .5;\n}<\/code><\/pre>\n\n\n\n

This is part of what the CSS Selectors Level 4 specification calls “time dimensional” pseudo-classes<\/a>, which is currently in Working Draft status. That means the specification is in progress and could change between now and when it becomes a candidate recommendation.<\/p>\n\n\n

WebVTT crash course<\/h3>\n\n\n

WebVTT is a format for creating subtitles, plotting them along a timeline with time ranges that define when each subtitle is displayed. This allows us to align subtitles with speech from media playback, such as videos.<\/p>\n\n\n\n

WEBVTT\n\n00:00:00.000 --> 00:00:03.000\n- [Birds chirping]\n- It's a beautiful day!\n\n00:00:04.000 --> 00:00:07.000\n- [Creek trickling]\n- It is indeed!\n\n00:00:08.000 --> 00:00:10.000\n- Hello there!<\/code><\/pre>\n\n\n\n

As the video plays, WebVTT is running alongside it, displaying the subtitles that are defined within the time ranges. That means there’s a time dimension where we have past, current, and future states for the subtitles. After a subtitle finishes playing, it becomes part of the past. That’s how this all relates to the :past<\/code> pseudo-element in CSS.<\/p>\n\n\n\n