Understanding the ::cue Pseudo-Element in CSS
The ::cue pseudo-element is used to style WebVTT (Web Video Text Tracks) cues in media elements like <video> or <audio>. It allows you to customize the appearance of subtitles or captions rendered by the browser.
::cue targets the text of a WebVTT track, such as subtitles or captions.
You can style properties like color, background, font-size, font-family, text-shadow, and line-height.
It applies only to text rendered from <track> elements associated with media.
Multiple ::cue selectors can be combined with conditions, e.g., ::cue(v[lang=en]) for language-specific styling.
In this example, all subtitles from the WebVTT track are displayed with yellow text on a semi-transparent black background, with a slight text shadow for readability.
Use ::cue to improve subtitle readability and match your site's design.
Test styling across different browsers, as some may render cues slightly differently.
Avoid overly decorative styles that could make subtitles hard to read.
Combine with accessibility guidelines to ensure subtitles are legible for all users.
How would you style the subtitles in a <video> element to be white with a black outline using CSS?
What happens if you try to use ::cue on a <video> that has no <track> element defined?
Our video player’s captions suddenly stopped responding to ::cue styles after we upgraded the frontend framework — what could be breaking this, and how would you debug it?
We’re using WebVTT captions, but ::cue styles only work in Chrome — how would you investigate and fix cross-browser inconsistency?
How would you design a themable video player that supports dynamic caption styling via ::cue while maintaining performance on low-end devices?
You need to support both custom ::cue styles and user-selected accessibility presets — how do you avoid CSS specificity conflicts and ensure the user’s choice always overrides defaults?
We’re migrating from a custom caption overlay system to native <track> + ::cue — what architectural tradeoffs do you consider around accessibility, performance, and legacy browser support?
How would you design a cross-team standard for media caption styling that ensures consistency across 20+ products while allowing product teams to customize appearance without breaking accessibility compliance?