HTML Background Music Code
This page contains the HTML code for setting background music on your webpage.
The following code sets background music. The important line is hidden="true"
. This is what makes it background music. If you didn't put that line, the user would see audio controls on the web page. Note that this code assumes that there is a music file at the specified location.
Here's the code:
See/hear the result. (Background music will start playing as soon as the page loads).
Add Audio Controls
To show the audio controls, just remove the hidden="true"
. You can also add autostart="false"
so that the music doesn't start playing as soon as the page loads.
The above HTML code results in this: