Background music | SoloLearn: Learn to code for FREE!

+2

Background music

Is it possible to code music that will play in the background in HTML, so that when a viewer opens my website the music will start playing automatically in the background. Thank-you in advance.

7/1/2020 4:35:16 PM

Владомир

7 Answers

New Answer

+4

Yes, it's possible… just add the autoplay attribute to the audio's object. However, the feature is limited on the sololearn app, you have to bind the play() method of the Audio's object to a HTML event, maybe onclick or when something done

+3

https://code.sololearn.com/WcaJTO58vAWm/?ref=app I created this code and it's working with music. You can get a reference from here and start coding. When a user opens a website means when body load (onload event in HTML) just play the music.

+1

I am not making website here, in Sololearn. I'm using an editor called "Sublime Text".

0

Can you show me the code, please?

0

If I understand correctly, the background music is working using nit only HTML , but JS as well. Am I right?

0

An also, may I ask another question, please? How can I make a button have more than one color? At the moment, I am making the project of my dream. By September it should be finished.

0