How to add background-music in html? | SoloLearn: Learn to code for FREE!


How to add background-music in html?

I tried using embed tag and bgsource tag it won't work.tell me your opinion through a example so that I would understand it properly?

7/12/2020 10:17:32 AM

shubham kumar

8 Answers

New Answer


Click the screen and the audio will be played


Create a variable in javascript using new Audio() like this song = new Audio(); song.src=""; here i have used faded song Then in html section use this in body tag <body onclick=""> So when someone clicks any where in output song starts playing due to onclick event attribute.

+2 Here is my code that may help you to insert a background music.


Thank you bro(Akshay Panwar) for help.



Your most welcome shubham kumar