You can add HTML background music code to your web page using the
This code will run music in the background as soon as the page loads. See/hear the result.
This results in:
hidden
attribute of the embed
tag. The embed tag isn't actually part of the HTML specification but it is still widely supported by the major browsers.Example Background Music Code
<embed name="lostmojo" src="/web_design/lostmojo.wav" loop="false" hidden="true" autostart="true"> </embed>
Adding Audio Controls
If you want your users to be able to control whether the background music plays or not, you can simply remove the hidden attribute (or change it to "false"). You can also add width and height to the controls. It's also a good idea to turn autostart off (autostart="false").
<embed name="lostmojo" src="/web_design/lostmojo.wav" loop="false" width="300" height="90" hidden="false" autostart="false"> </embed>
This results in: