Video
A frame that keeps a video's shape on every screen (16:9 unless you say otherwise), for your own <video> or an embedded player. And a "click to play" cover that only loads the player when pressed, so the page stays fast and nothing loads from a video site until the reader asks for it.
Click to play
A button.video.video-facade with a poster picture and data-momo-video. Pressing it swaps in the player and starts it.
<button class="video video-facade" type="button" data-momo-video="../examples/img/sample-clip.webm" aria-label="Play: Sunrise over the hills, 6 seconds">
<img src="../examples/img/sample-clip-poster.png" alt="" width="960" height="540">
<span class="video-play" aria-hidden="true"><i class="mi mi-play-filled"></i></span>
<span class="video-label"><b>Sunrise over the hills</b><span>0:06</span></span>
</button>For YouTube or Vimeo, put their embed address in data-momo-video (YouTube's youtube-nocookie.com address sets no cookies until the video plays):
<button class="video video-facade" type="button" data-momo-video="https://www.youtube-nocookie.com/embed/VIDEO_ID" aria-label="Play: How Momo works">
<img src="poster.jpg" alt="">
<span class="video-play" aria-hidden="true"><i class="mi mi-play-filled"></i></span>
</button>
Your own video
<div class="video">
<video controls preload="none" poster="../examples/img/sample-clip-poster.png">
<source src="../examples/img/sample-clip.webm" type="video/webm">
</video>
</div>Shapes
<div class="video video-4x3 w-48"><img src="../examples/img/sample-5.svg" alt="4:3 frame"></div>
<div class="video video-1x1 w-36"><img src="../examples/img/sample-6.svg" alt="Square frame"></div>
<div class="video video-9x16 w-28"><img src="../examples/img/sample-7.svg" alt="Tall 9:16 frame"></div>Classes
| Class / attribute | Does |
|---|---|
.video | A 16:9 frame; the iframe, video or img inside fills it |
.video-4x3 / -1x1 / -21x9 / -9x16 | Other shapes (or set --video-ratio); 9:16 is for phone videos and stays at most 352px wide |
.video-facade + data-momo-video="url" | The click-to-play cover; a .mp4 / .webm plays in a <video>, anything else in an <iframe> |
.video-play / .video-label | The round play button / a title bar along the bottom |
Accessibility
- Name the cover button after the video ("Play: How Momo works"); the player gets that name as its title.
- Add captions to your own videos with a
<track kind="captions">. - Never autoplay with sound. The cover only plays after a press.