How To Embed Sound on a Web Page

Media Player
soulcld/iStock Vectors/Getty Images

Embedding sound is tricky. You have to choose between a method that works but is not valid HTML or a method that isn't valid but doesn't work on most browsers. This tutorial teaches you how to write both in HTML so that when the valid option gains support, you can remove the invalid option from your pages. You'll learn the HTML required so that you can do it in any HTML editor.

Difficulty: Average

Time Required: 10 minutes

Here's How:

  1. Open your Web page in an HTML editor. Your editor must have the ability to edit the source code to follow this tutorial.
  2. Start with an object element:
  3. You'll add 4 parameters to the object. The first is "src" that tells the browser where to find the sound file. In this example, the sound file is eureka.wav and is found in the same directory as the Web page:
  4. If you want the sound file to play immediately after it's loaded, make the autostart parameter "true" otherwise make it "false":
  5. The parameter autoplay is similar to autostart, just used by other browsers, set it the same as the autostart parameter:
  6. Use the controller parameter to tell the browser if a controller should be displayed to give your readers more control over the sound:
  7. Inside the element, add an embed element:
  8. Add the following four attributes that are the same as the parameters to the object:
  9. Add the correct MIME type for your sound file into the type attribute:
  1. Add the plugins page attribute so that people who don't have the correct plugin for your sound file can go download it. For WAV files, I recommend QuickTime:
  2. When you're done, your HTML should look like this:



  1. Don't validate your Web page with the embed tag. It won't validate because that tag is not part of the specification. But only Safari supports the object tag for sound.
  1. Check out the embed tag for additional attributes. Many of them you can use as parameters on your object as well.
  2. I recommend always setting the controller="true" attribute. That way, if someone doesn't want to hear sound on your Web page, they can turn it off.
  3. For the most accessible (and valid) sound, just link to your sound file.
    Eureka sound file
    That gives your customers the choice to listen or not.

What You Need:

  • HTML Editor
  • Sound file
mla apa chicago
Your Citation
Kyrnin, Jennifer. "How To Embed Sound on a Web Page." ThoughtCo, May. 9, 2017, Kyrnin, Jennifer. (2017, May 9). How To Embed Sound on a Web Page. Retrieved from Kyrnin, Jennifer. "How To Embed Sound on a Web Page." ThoughtCo. (accessed February 21, 2018).