Skip to main content

The <source> Element

As defined in the HTML Living Standard, the <source> element allows authors to specify multiple alternative media resources for <picture>, <audio>, and <video> elements. It is a void element.

Visual Example (Art Direction):

Demonstration of responsive sources.

(Resize your window to see different sources take effect.)

<video controls> <source src="movie.webm" type="video/webm"> <source src="movie.mp4" type="video/mp4"> Your browser does not support the video tag. </video> View HTML Living Standard: The source element

Usage in Different Contexts

The attributes required on a <source> element change based on its parent:

WCAG Principle: Robustness

Success Criterion 1.1.1 (Level A): All non-text content that is presented to the user has a text alternative.

The <source> tag itself is a technical instruction for the browser and does not have an alt attribute. Accessibility is managed by the parent element. In a <picture>, the alt text must be on the required <img> child. In media elements, you must provide fallback text or transcripts alongside the source list.

Understand SC 1.1.1: Non-text Content

Performance and Accessibility

Providing multiple sources is an act of inclusive design. It ensures that:

A11y Tip: Logical Ordering

Browsers evaluate <source> elements in the order they appear and choose the first one that is compatible. Always place your highest-quality or most efficient formats first, followed by the most compatible ones.