::cue CSS Pseudo Element
Description
The ::cue pseudo-element in CSS is used to style WebVTT (Web Video Text Tracks) cues, which are the timed text snippets displayed in video or track elements. It allows developers to control the appearance of captions, subtitles, or any other kind of text track directly with CSS, offering options for visual customization such as font, color, background, and text alignment. This pseudo-element applies only to the text of the cue itself, not the entire container of the video or track.
The ::cue pseudo-element supports styling properties including color, background-color, font-size, font-family, text-shadow, and white-space. These properties allow precise control over text readability and visual appeal. However, more complex layout properties such as margins or padding are generally not supported within ::cue, since cues are rendered in an overlay by the browser’s internal media rendering engine.
A key feature of ::cue is that it can be combined with selectors that target specific cues based on their voice, id, or class in the WebVTT file. For example, if a cue in the track file has a class, it can be styled like this:
::cue(.speaker1) {
color: yellow;
background-color: rgba(0, 0, 0, 0.6);
font-size: 1.2em;
text-shadow: 1px 1px 2px black;
}
This makes it possible to differentiate speakers or emphasize certain types of cues. The pseudo-element can also be used without a class to style all cues globally:
::cue {
color: white;
background-color: rgba(0, 0, 0, 0.8);
font-size: 16px;
font-family: Arial, sans-serif;
}
Another useful capability is combining ::cue with media queries to adapt caption styling depending on screen size or device capabilities. For instance:
@media (max-width: 600px) {
::cue {
font-size: 14px;
}
}
This ensures captions remain legible on smaller devices without altering their appearance on larger screens. Overall, ::cue provides a powerful, flexible way to enhance accessibility and user experience in video playback through precise text styling.
Syntax
::cue | ::cue(<selector>) {
/* ... */
}Example
Browser Support
The following information will show you the current browser support for the CSS ::cue pseudo element. Hover over a browser icon to see the version that first introduced support for this CSS pseudo element.
Desktop





Tablets & Mobile





