# .ogg

> The `.ogg` is a container format that can hold audio, video and metadata, with the most common audio codec being Vorbis, which offers high-quality compression.

## What is an OGG file and can browsers play it?

The open-source container format, commonly used with the Vorbis audio codec. It provides high-quality audio compression and is used in streaming services and video games.

- Topic: Audio
- Type: format

## Example

Wrong:

```html
<audio controls>
  <source src="theme.ogg">
</audio>
```

Right:

```html
<audio controls>
  <source src="theme.ogg" type="audio/ogg; codecs=vorbis">
  <source src="theme.mp3" type="audio/mpeg">
</audio>
```

With a `type` the browser skips sources it cannot play without downloading them, and the MP3 covers the rest.

## Common mistakes

- Treating Ogg as a codec, while it is a container that can hold Vorbis, Opus or other streams.
- Shipping only `.ogg` audio, so some browsers play nothing.

## Key points

- The `<source>` type names the codec inside, such as 'audio/ogg; codecs=opus' or 'audio/ogg; codecs=vorbis'.
- An `.ogg` source is followed by an `.mp3` or `.m4a` fallback for browsers that cannot play it.

## Interview questions

### Is OGG the same as Vorbis?

No. Ogg is a container and Vorbis is an audio codec often stored in it. An `.ogg` file can also hold Opus or other codecs.

### OGG vs MP3: which is better?

Ogg Vorbis often sounds better than MP3 at the same bit rate and is royalty free. MP3 plays on more devices.

### Why do games use OGG audio?

Ogg Vorbis is free of licensing fees, compresses well and loops cleanly, which suits game music and effects.

## Related cards

- [.opus](https://wonderium.dev/engineering/opus.md)
- [.mp3](https://wonderium.dev/engineering/mp3.md)
- [.webm](https://wonderium.dev/engineering/webm.md)
- [`<source>`](https://wonderium.dev/html/source.md)

---

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