# .webm

> The `.webm` is an open, royalty-free media container designed for the web that holds VP8, VP9 or AV1 video and Vorbis or Opus audio.

## What is WebM and how do I use it with an MP4 fallback?

The open-source video format optimized for online streaming. It supports high-quality video and low latency, making it popular for web video playback and supported by most modern browsers.

- Topic: Video
- Type: format

## Example

Wrong:

```html
<video controls>
  <source src="clip.mp4" type="video/mp4">
  <source src="clip.webm" type="video/webm">
</video>
```

Right:

```html
<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 a `type` attribute.
- The `type` can 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.

## Related cards

- [.mp4](https://wonderium.dev/engineering/mp4.md)
- [`<video>`](https://wonderium.dev/html/video.md)
- [`<source>`](https://wonderium.dev/html/source.md)
- [.opus](https://wonderium.dev/engineering/opus.md)
- [.mkv](https://wonderium.dev/engineering/mkv.md)

---

- Level: [Engineering](https://wonderium.dev/engineering.md)
- HTML version: https://wonderium.dev/engineering/webm
- Last updated: 2026-11-25
