.webm
Example
<video controls>
<source src="clip.mp4" type="video/mp4">
<source src="clip.webm" type="video/webm">
</video><video controls>
<source src="clip.webm" type="video/webm">
<source src="clip.mp4" type="video/mp4">
</video>Browsers take the first source they can play, so the smaller WebM goes first and MP4 catches the rest.
Common mistakes
- Shipping WebM only, so some devices show an empty player.
- Listing the MP4 source first, so browsers that could use the smaller WebM never pick it.
Key points
- The WebM
<source>comes before the MP4 one, and both have atypeattribute. - The
typecan name codecs, like 'video/webm; codecs="vp9, opus"', so unsupported files are skipped. - Transparent video uses WebM with an alpha channel and has a fallback for browsers without alpha support.
Interview questions
WebM vs MP4: which is smaller?
With VP9 or AV1, WebM is often smaller than H.264 MP4 at the same quality. MP4 with AV1 is similar in size.
Is WebM royalty free?
Yes. WebM and its codecs VP8, VP9, AV1, Vorbis and Opus are open and royalty free.
Can WebM video have a transparent background?
Yes. VP8 and VP9 in WebM support an alpha channel, which is used for overlays and stickers.