How To Add Video and Audio on HTML

How To Add Video and Audio on HTML

•Introduction •The HTML Audio •The Audio Syntax •The HTML Video •The Video Syntax •Conclusion

Introduction

Adding audio or video to your HTML can be very simple, if you know the syntax. You will have to use the src attribute to locate video or audio source and to add an autoplay control to the attributes so the user can play and pause the media. The and tags make it easy to add media.

The HTML Audio

The controls attribute helps to add audio controls like play, pause, and volume.

The source elements allow the browser to choose from alternative audio files. The browser will use the first recognized format. The text between the <audio> and the </audio> tags will only be shown in browsers that do not support the <audio> element

The Audio Syntax

< audio controls autoplay> < source src="audio file.ogg" type="audio/ogg"> < source src="file.mp3" type="audio/MPEG"> Your browser does not support the audio element. </audio>

The HTML Video

The <video>tag is used to show a video on the webpage. The control attribute adds video controls also just like the audio controls. It is very suitable to use the width and the height attributes because if they are not included the page might quiver while the video ahows. The source elemnt allows the browser to choose from the first recognized format.

The Video Syntax

< video width="350" height="270" autoplay> < source src="movie.mp4" type="video/mp4" < source src="movie.ogg" type="video/Ogg"> Your browser does not support the video tag. <\video>

Conclusion

This would help you add video and audio to your HTML projects. Stay tuned to my blog!. For more solutions to coding.