O'Reilly logo

Web Programming with HTML5, CSS, and JavaScript by Dean

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.6 Audio

So far in this chapter, we’ve focused on visual media with images. Now it’s time to move on to audio media. In this section, you’ll learn how to implement an audio player with the audio element.

Prior to HTML5, end users had to install a plug-in to play sound from a web page. Now there’s no need for that. Today’s browsers include a built-in audio player that’s used in conjunction with the audio element. Here’s a simple audio element example:

<audio src="../audio/witchesCackle.mp3" preload="auto" controls>
  </audio>

Note that the audio element requires a start tag and an end tag, even though there’s no content between the tags. Later you’ll see an example where there is content between the tags.

audio Element Attributes

In the prior ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required