References

Collection of references for web development.

HTML source tag

Description

The HTML <source> element represents multiple media resources for the <audio>, <picture>, or <video> element.

Attributes

Attribute Value Description
media Operators: and|not|,
Devices: all, print, screen, speech
Values: aspect-ratio, color, color-index, grid, height, monochrome, orientation, resolution, scan, width
Specifies the media type for which the element or the document is designed for.
sizes list Specifies image sizes for different document sizes.
src URL The URL of the file to embed in the document.
srcset list Specifies a list of resources to be used for different conditions.
type MIME type Specifies the media type for the URL.

Example

<picture>
	<source media="(min-width: 600px)" srcset="https://via.placeholder.com/300x150">
	<source media="(min-width: 300px)" srcset="https://via.placeholder.com/150x50">
	<img src="https://via.placeholder.com/450x200" alt="Placeholder">
</picture>