Style WebVTT captions with CSS's ::cue selector, either in a STYLE block inside the .vtt file or in the stylesheet of the page playing the video. Only a few properties apply — colour, background, font, text-shadow and some others — and position is not one of them: that lives in cue settings after the timestamp.
The syntax is CSS. The rules are narrower, and the viewer gets the last word.
A WebVTT file can carry its own look. The format borrowed CSS for it: a STYLE
block near the top of the file holds ordinary-looking rules, and the selector they use is
::cue, which means "the caption text". A minimal styled file looks like this:
WEBVTT
STYLE
::cue {
color: #ffd93d;
background-color: rgba(0, 0, 0, 0.8);
}
00:00:01.000 --> 00:00:02.400
Yellow text on a dark box.
Three things make it different from styling a page. First, only a short list of properties
works on ::cue: the colour, opacity and visibility properties, text-decoration,
text-shadow, the background properties, the outline properties, the
font properties including line-height, white-space, and two
specialised ones for vertical and ruby text. There is no padding, no border, no rounded corners,
no margin and no positioning. Second, where the caption sits is not CSS at all; it is set per cue,
in settings written after the timestamp. Third, the viewer can override you: caption preferences in
the operating system or the player can replace some or all of what the file asks for, and for
accessibility that is the correct order of priority.
What people usually want from a caption, and the closest thing the format allows.
| You want | In WebVTT | The catch |
|---|---|---|
| Text colour | color | None |
| Font and weight | font-family, font-weight, font-style | The viewer needs the font, or the player substitutes one |
| Size | font-size as a percentage | Relative to the player's own default caption size, not the video |
| A box behind the text | background-color, with rgba() for transparency | No padding and no rounded corners |
| An outline | A ring of text-shadow offsets | No stroke property is allowed |
| A soft shadow | text-shadow with a blur | None |
| One word in another colour | A <c.name> span and a ::cue(.name) rule | None |
| Top, middle or bottom | The line: cue setting | Not CSS; see subtitle position |
| The spoken word highlighted | Timestamp tags with :past / :future | Uneven support across players |
Two of those deserve a word more. A percentage font-size on ::cue
scales the player's default caption size, whatever that happens to be, so the only way to state a
size is as a ratio to it. And because there is no -webkit-text-stroke or any other
stroke on the allowed list, an outline has to be faked: several hard-edged shadows, each offset a
little in a different direction, so that together they ring every letter. Four offsets leave the
diagonals of round letters visibly thinner than their sides; eight look like a real outline.
Exactly what suubbs writes for its Pop look — Inter Tight, black weight, upper case, a dark outline — with one word recoloured.
WEBVTT
STYLE
::cue {
color: #ffffff;
font-family: "Inter Tight";
font-size: 132%;
font-weight: 700;
font-style: normal;
letter-spacing: 0.01em;
line-height: 1.24;
background-color: transparent;
text-shadow: 0.138em 0em 0 #17161a, 0.098em 0.098em 0 #17161a, …;
}
STYLE
::cue(.s1) {
color: #ffd93d;
}
00:00:01.000 --> 00:00:02.400
MADE ON MY <c.s1>MAC</c>
font-size: 132% — the look is 6.6% of the video's height, and a
browser's own default caption is about 5%, so suubbs states it as the ratio between the two.text-shadow carries the outline: eight offsets in a ring, in
em, so the outline keeps its weight relative to the letters at any player size. The
line is shortened here; the file has all eight.s1, declared once in its
own STYLE block and applied with a <c.s1> span. A colour used on forty
words is still one rule.Three small losses are worth knowing about. WebVTT gets a bold weight as 700, so suubbs' black
weight arrives as ordinary bold. The letter-spacing line is written, but it is not on
the ::cue allowed list, so browsers ignore it. And the rounded corners the preview
can give a box have no equivalent, since border-radius is not allowed.
The same rule works in two places, and they fail in different ways.
The block goes after the WEBVTT header line and before the first cue, separated
from both by blank lines, and it may not contain the string -->. A block placed
after a cue is not treated as a style block. The advantage is that the look travels with the file
to any player that reads it. The weakness is that not every player does: support has varied
between browsers, and many players and upload forms take a .vtt for its words and timings only.
If the styling matters, test the exact player your audience uses.
If you control the web page the video plays in, you can put the same rules in its ordinary CSS:
video::cue {
color: #ffffff;
background-color: rgba(12, 11, 16, 0.92);
}
video::cue(.s1) {
color: #ffd93d;
}
This styles every caption track on those video elements, which is useful when you publish many videos with one look and do not want it repeated in every file. The same allowed-property list applies.
padding, border,
border-radius and margin are silently ignored on ::cue.STYLE block after the first
cue does not count.STYLE blocks.If you are starting from the video rather than an existing file, the CSS can come out of a live preview instead of a text editor.
::cue rule for the document and
one class for each distinct override, as in the example above. If the anchor or edge offset was
changed, the cue settings carry it.Before the file is written, suubbs names what WebVTT cannot hold from what you set, rather than
dropping it quietly: a word-by-word highlight, fades, and a caption dragged to a free position.
A document nobody styled is exported as a bare WebVTT file with no STYLE block at all,
so the player's own look applies. For captions that must look exactly as designed — on TikTok or
Reels, say, where a caption file is not uploaded — burn them into the picture from an ASS export
instead; burning subtitles into a video covers it.
Already have an SRT and only need the format changed? Converting SRT to VTT is a one-line job and does not need suubbs. How size behaves across SRT, WebVTT and ASS is on subtitle font size.
Yes. WebVTT captions are styled with the ::cue pseudo-element, either in a STYLE block inside the .vtt file or in the stylesheet of the page that plays the video. Only a limited set of properties applies: colour, background, font, text-shadow, outline, opacity and a few others. Position is set with cue settings, not CSS.
After the WEBVTT header and before the first cue, separated by blank lines. It may not contain the string -->. A block placed after a cue is not treated as a style block.
Usually one of three things: the player does not read STYLE blocks from inside the file, the viewer's own caption settings are overriding yours, or the property is not one ::cue allows. Test in the player your audience actually uses, and try the same rule in the page's stylesheet.
Set background-color on ::cue, with an rgba() value if you want it partly transparent. Padding and rounded corners are not allowed properties, so the box hugs the text and has square corners.
There is no stroke property on the ::cue allowed list, so draw the outline with text-shadow: several shadows offset in a ring around each letter. suubbs writes eight, in em units, so the outline keeps its weight at any caption size.
The format has inline timestamp tags and :past and :future pseudo-classes meant for that, but support across players is uneven. suubbs does not write them; for highlighted captions it exports ASS for a burn-in, and warns that WebVTT cannot carry the highlight.