Home > Web Front-end > HTML Tutorial > How to set the URL of a media file in HTML?

How to set the URL of a media file in HTML?

WBOY
Release: 2023-09-10 09:05:08
forward
1322 people have browsed it

How to set the URL of a media file in HTML?

In this article, we will learn how to set the URL of a media field in HTML.

Here, we will learn how to use HTML to create URLs for media files. We use the tag to specify the URL of the media file. Multimedia files (including audio, video, and image files) are attached using this tag. The element is contained within the

grammar

The following is the syntax of the element

<source src="" type="">…….</source>
Copy after login

Let’s dive into the following example to learn more about how to set media file URLs in HTML.

Example 1

In the following examples, we use the audio tag.

<!DOCTYPE html>
<html>
<body style="text-align: center;">
   <audio id="varma" controls>
      <source src="https://samplelib.com/lib/preview/mp3/sample-3s.mp3" type="audio/mpeg">
   </audio>
</body>
</html>
Copy after login

When the script executes, it will generate an output showing the audio files uploaded to the web page using the tag.

Example 2

Consider the following example where we use the tag with a video.

<!DOCTYPE html>
<html>
<body>
   <video width="400" height="350" controls>
      <source src="https://static.videezy.com/system/resources/previews/000/052/918/original/21.mp4"">
   </video>
</body>
</html>
Copy after login

When you run the above script, it will generate an output that contains the text used in the script as well as the colspan on the web page.

Example 3

Let's look at another example where we use the tag with an image.

<!DOCTYPE html>
<html>
<body>
   <h1>ELEPHANTS</h1>
   <p>Elephants are the largest existing land animals.</p>
   <p><br><img  src="https://www.tutorialspoint.com/assets/questions/media/500267-1671169181.png" alt="How to set the URL of a media file in HTML?" ></p>
</body>
</html>
Copy after login

If the script is executed, an output window will pop up showing the image uploaded to the web page using the tag.

The above is the detailed content of How to set the URL of a media file in HTML?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template