<source>
One of the file versions for `<video>`, `<audio>` or `<picture>`.
Syntax
<source src="file.webm" type="video/webm">Attributes
| Parameter | Type | Description |
|---|---|---|
| src | URL | The file address (inside `<video>` and `<audio>`). |
| srcset | URL list | Image addresses (inside `<picture>`). |
| type | MIME type | The file format: the browser skips what it cannot play. |
| media | media query | Only in `<picture>`. Which screens this version is for. |
Examples
A video in two formats:
<video controls width="300">
<source src="/media/flower.webm" type="video/webm">
<source src="/media/flower.mp4" type="video/mp4">
Your browser does not support video.
</video>Notes
The browser checks the <source> elements in order and takes the first that fits, so put the lightest modern format first. The tag is single.
See also
Related recipes
In the tutorial
- Audio and video — The video and audio tags, the controls panel, autoplay, looping, several formats with source and subtitles.