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 ...

Get Web Programming with HTML5, CSS, and JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.