Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

<source>

One of the file versions for `<video>`, `<audio>` or `<picture>`.

Syntax

<source src="file.webm" type="video/webm">

Attributes

ParameterTypeDescription
srcURLThe file address (inside `<video>` and `<audio>`).
srcsetURL listImage addresses (inside `<picture>`).
typeMIME typeThe file format: the browser skips what it cannot play.
mediamedia queryOnly 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

  • <video> — Embeds a video in the page.
  • <audio> — Embeds an audio player.
  • <picture> — A container for several versions of an image: the browser picks a matching `<source>` or falls back to `<img>`.

Related recipes

In the tutorial

  • Audio and video — The video and audio tags, the controls panel, autoplay, looping, several formats with source and subtitles.

Thanks for reading!

Donate to the site — we work hard for you.