CSS Portal

::cue CSS Pseudo Element

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
::cue
CSS Pseudo ElementThis pseudo element is supported by all modern browsers.
Updated 31st December 2025

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

<body>

<video controls width="600">
<source src="movie.mp4" type="video/mp4">
<track default kind="captions" srclang="en" src="subtitles.vtt">
Your browser does not support the video tag.
</video>

</body>
/* Styles all subtitles/captions */
video::cue {
background-image: linear-gradient(to bottom, #444, #111);
color: #fff;
font-family: "Helvetica", sans-serif;
font-size: 1.2rem;
text-shadow: 2px 2px 2px #000;
}

/* Styles only bold <b> tags within the VTT file */
video::cue(b) {
color: #ffcc00;
}
Open in editor

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.

This pseudo element is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee