How to insert audio in html | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to insert audio in html

20th May 2020, 5:55 AM
---------
2 Answers
+ 1
<audio controls> <source src="audio.mp3" type="audio/mpeg"> <source src="audio.ogg" type="audio/ogg"> </audio>
22nd May 2020, 2:58 AM
Poornitha Yasas
Poornitha Yasas - avatar
+ 2
Use the <source> element inside the <audio> element: <audio controls> <source src="audio.mp3" type="audio/mpeg"> <source src="audio.ogg" type="audio/ogg"> Audio element not supported by your browser </audio> You must place the file with mp3, ogg or wav extension in the folder where your .html file is so that it works normally. I recommend this way and I suggest you save the audio file in at least two different formats mp3 and ogg. If the mp3 format file cannot be played in the browser then it will select the second option in this case ogg format if it also fails then the alternative text will be displayed (Audio element not supported by your browser). Regards
22nd May 2020, 8:08 AM
Roosvelt Balza
Roosvelt Balza - avatar