Techoceanhub logo

Adding video and audio content in HTML

To add video and audio content in HTML, you can use the <video> and <audio> elements respectively. Here’s how you can do it:

Adding Video:

<video src="path/to/video.mp4" width="640" height="480" controls>
  Your browser does not support the video tag.
</video>

In the above example, replace "path/to/video.mp4" with the actual path or URL of your video file. The width and height attributes specify the dimensions of the video player, and the controls attribute enables the default video controls (play, pause, volume, etc.). The text within the <video> element is displayed if the browser does not support the video tag.

Adding Audio:

<audio src="path/to/audio.mp3" controls>
  Your browser does not support the audio tag.
</audio>

Similar to the video element, you need to replace "path/to/audio.mp3" with the actual path or URL of your audio file. The controls attribute adds audio controls to the player. The text within the <audio> element is displayed if the browser does not support the audio tag.

You can also customize the appearance and behavior of the video and audio elements using CSS and JavaScript. Additionally, HTML5 supports multiple video and audio formats, so you can provide alternative sources by using the <source> element within the <video> or <audio> element. This allows the browser to select the appropriate format based on its capabilities.

Here’s an example of using multiple sources for a video:

<video width="640" height="480" controls>
  <source src="path/to/video.mp4" type="video/mp4">
  <source src="path/to/video.webm" type="video/webm">
  Your browser does not support the video tag.
</video>

In the above example, the browser will try to play the video.mp4 file first, and if it’s not supported, it will fall back to the video.webm file.

Share:

Categories

Archives

Related Posts

Array Destructuring

Array Destructuring Array destructuring is a powerful syntax introduced in ES6 that allows you to unpack elements from an array

Read More »

Explore our Affiliated partner links

hostgator website plan

Hostgator

Best Website hosting plans & Best for 24/7 support.

hostinger webhosting plan

Hostinger

Reasonable website hosting packages for small business & 24/7 Email support

Elementor pro

Design Worpdress website quickly using Elementor Builder and AI

buy elementor website templates

Buy Elementor Website Template

Buy ready made Elementor Website Template from us & Get Free Elementor pro licence for 1 year .