Introduction
The <source> element in HTML is used as a child of media elements like <audio> and <video>, as well as the <picture> element for responsive images. It specifies multiple media resources for the browser to choose from, allowing for better compatibility and optimization across different devices and browsers.
Here’s an example:
#.Within <audio> or <video> elements:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Source Example</title>
</head>
<body>
<video controls>
<source src="cars.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</body>
</html>
Outout:
In this example we give a source of video and it will display on the webpage. As well as we can make for picture.