HTML Tutorial
The <source> tag is used to specify multiple media sources for a <video> or <audio> element. It allows browsers to select the most appropriate source based on factors such as file format, resolution, and bitrate.
<video>
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm">
</video>
In this example, browsers will first try to load and play the video.mp4 file. If the browser does not support the MP4 format, it will fall back to the video.webm file.
Exploring the <source> Tag
<!DOCTYPE html>
<html>
<head>
<title>Exploring the <source> Tag</title>
</head>
<body>
<video controls>
<source src="my-video.mp4" type="video/mp4">
<source src="my-video.webm" type="video/webm">
</video>
</body>
</html>
The <source> tag supports accessibility by providing multiple media formats, ensuring that users with different devices and preferences can access the content. Additionally, browsers can use the media conditions in the <source> tag to automatically select the most suitable source for the current viewing environment.