how we can insert music on html and html5 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how we can insert music on html and html5

11th Aug 2016, 3:20 AM
diwakar Kumar
diwakar Kumar - avatar
3 Answers
+ 8
To play an audio file in HTML, use the <audio> element: Example: <audio controls>   <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> </audio> The controls attribute adds audio controls, like play, pause, and volume. Multiple <source> elements can link to different audio files. The browser will use the first recognized format. The <type> element must be included in <audio>. If the file searched is mp3 the type tag will be type="audio/mpeg". If the file searched is ogg the type tag will be type=" audio/ogg. Currently, there are 3 supported file formats for the <audio> element: MP3, Wav, and Ogg: Browser MP3 Wav Ogg InternetExplorer. YES NO NO Chrome YES YES YES Firefox YES YES YES Safari YES YES NO Opera YES YES YES HTML5 Audio tags: <audio> - Defines sound content <source> - Defines multiple media resources for media elements, such as <video> and <audio> - Dumitru If this answer has helped you, give it a upvote by pressing the button that looks like an thumbs up (like).
11th Aug 2016, 9:38 AM
Dumitru Comarnitchi
Dumitru Comarnitchi - avatar
+ 1
put your html file and one of your mp3 file in same folder and then put this code in body tag: <audio controls> <source src="put your mp3 file name" type="audio/mpeg"> <source src="audio.ogg" type="audio/ogg"> Audio element not supported by your browser </audio>
11th Aug 2016, 3:59 AM
Mahdi
Mahdi - avatar
+ 1
use the tag <audio src="name of file.extincton" autoplay/controls"type=extiction
12th Aug 2016, 12:38 AM
KoduruSivaGowthamReddy
KoduruSivaGowthamReddy - avatar