Quackit Logo
Sponsored Links
$1.99 Domain Names
With every new non-domain purchase thru ZappyHost, you get a domain name for only $1.99.
FREE Hosting!
With every domain you register with ZappyHost you get FREE hosting.
Create a website for free - uCoz
Build a website quickly and easily Customizable templates and graphics

HTML Background Music Code

Print Version

You can add HTML background music code to your web page using the 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>

This code will run music in the background as soon as the page loads. See/hear the result.

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:

Have you checked out the HTML Tutorial?

Enjoy this website?

  1. Add this page to your Favorites
  2. Link to this page (copy/paste into your own website or blog):
  3. Help support Quackit by making a donation
  4. Add this page to your favorite social bookmarks sites:      

Oh, and thank you for supporting Quackit!