"I am Saqib Jahangir. A passionate vlogger, software engineer, and avid traveler with a deep love for exploring the hidden gems of our beautiful planet. With a strong foundation in Application Development, Application Architecture & Database Design and Product Management, I bring over a decade of hands-on experience building secure, scalable, and resilient web applications for a diverse range of industries."

Multimedia Tags

 

Adding multimedia content like audio, video, or embedding other websites makes your webpages richer and more engaging. HTML provides special tags for this.


1. <audio>

The <audio> tag is used to embed sound files on your webpage, such as music or podcasts.

Basic Syntax:

<audio controls>

  <source src="sound.mp3" type="audio/mpeg">

  Your browser does not support the audio element.

</audio>

  • controls: Adds play, pause, volume controls.
  • <source> specifies the audio file and its format.
  • The text inside <audio> is fallback content for browsers that don’t support it.

Example:

<audio controls>

  <source src="song.mp3" type="audio/mpeg">

  Your browser does not support the audio element.

</audio>


2. <video>

The <video> tag is used to embed video files.

Basic Syntax:

<video width="640" height="360" controls>

  <source src="movie.mp4" type="video/mp4">

  Your browser does not support the video tag.

</video>

  • width and height: Control the size of the video player.
  • controls: Shows play, pause, and volume controls.

Example:

<video width="640" height="360" controls>

  <source src="sample-video.mp4" type="video/mp4">

  Your browser does not support the video tag.

</video>


3. <iframe>

The <iframe> tag lets you embed another webpage inside your page — like a YouTube video, Google Maps, or another website.

Basic Syntax:

<iframe src="https://www.example.com" width="600" height="400" frameborder="0"></iframe>

  • src: URL of the page you want to embed.
  • width and height: Size of the iframe.
  • frameborder="0" removes the border around the iframe (optional).

Example: Embed a YouTube Video

<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ"

    title="YouTube video player" frameborder="0" allowfullscreen>

</iframe>


Practice with XAMPP/WAMP

  1. Create a file multimedia.html in your server folder.
  2. Paste the following:

<!DOCTYPE html>

<html>

<head>

  <title>Multimedia Examples</title>

</head>

<body>

 

  <h2>Audio Example</h2>

  <audio controls>

    <source src="audio-file.mp3" type="audio/mpeg">

    Your browser does not support the audio element.

  </audio>

 

  <h2>Video Example</h2>

  <video width="480" height="270" controls>

    <source src="video-file.mp4" type="video/mp4">

    Your browser does not support the video tag.

  </video>

 

  <h2>Iframe Example</h2>

  <iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ"

      title="YouTube video player" frameborder="0" allowfullscreen></iframe>

 

</body>

</html>

  1. Replace "audio-file.mp3" and "video-file.mp4" with your actual media files stored locally or online URLs.
  2. Open the page in your browser to see audio, video, and embedded content.

 

Popular Posts

Setting Up Your First Project Folder and Installing XAMPP or WAMP

Frontend vs Backend vs Full Stack