0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
The image a video shows before playback starts. Pairs with preload=none for bandwidth savings; VB players and data-mock set it for you.
Overview
The posterattribute gives a video an image to show until playback starts. Without one, the browser shows the first frame once it has loaded, or an empty box if no video data has loaded yet (for example with preload="none").
A good poster tells people what the video is, makes it obvious that there is something to play, and stops the box flashing blank while the page loads.
<videocontrolspreload="none"width="960"height="540"poster="poster.jpg"><sourcesrc="sample.mp4"type="video/mp4"><p><ahref="sample.mp4"download>Download the video</a></p></video>
Values
Value
Meaning
A URL
Show this image before playback. Must be non-empty. Any image format the browser can decode works.
(absent, the default)
Show the first frame once it is available, otherwise nothing.
Empty, or the image fails to load
Treated as no poster.
The poster shows until playback starts or the user seeks. After that the current frame stays on screen, even when paused.
Examples
Reserve the space
Give the video width and height attributes so the browser reserves the right box before the poster loads, and make the poster the same aspect ratio as the video. A poster with a different shape is letterboxed inside the box. VB makes every video fluid (max-inline-size: 100%; block-size: auto), so no inline style is needed.
Width and height reserve the box
12345
<videocontrolswidth="1920"height="1080"poster="tutorial-poster.jpg"><sourcesrc="tutorial.webm"type="video/webm"><sourcesrc="tutorial.mp4"type="video/mp4"><p><ahref="tutorial.mp4"download>Download the tutorial</a></p></video>
With several <source> elements, poster still goes on the <video>.
Hero video and LCP
A poster above the fold can be the page's Largest Contentful Paint element. To start its download as early as possible, preload it at high priority:
There is no srcset for posters: the browser loads the one URL. Make the poster the size of the largest box it fills and compress it well (AVIF or WebP), or swap it from script when your layout changes.
In Vanilla Breeze
Video defaults.src/native-elements/video/styles.css gives every video max-inline-size: 100%, block-size: auto, display: block and a dark background (--color-gray-900) that shows while the poster loads. The .widescreen, .standard and .ultrawide classes set an aspect ratio and letterbox with object-fit: contain; add .cover to crop instead.
<video-player> keeps the inner video's poster. In playlist mode, a track link's data-poster becomes the video's poster when that track is selected (src/web-components/video-player/logic.js).
<youtube-player poster> uses your local image for the facade instead of fetching the thumbnail from i.ytimg.com, so nothing is requested from Google until the user presses play.
data-mock on a <video> without a poster writes a placeholder SVG poster, labelled from alt or title (src/utils/mock-init.js).