×

html · level 2 · unit 7 · lesson 2

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

plays sound, and <source> offers spare formats.

<audio controls> adds a player for audio: a slim bar with play, pause and volume. It works like <video>, with no picture. Without controls, an audio player is not shown at all.

Files come in different formats, shown by their ending, and not every browser plays every . So list each file in its own <source>, with type naming the format. The browser plays the first one it can.

type="audio/mpeg" means .mp3, and type="audio/ogg" means .ogg. <video> uses <source> the same way, with video/mp4 and video/webm.

<figure>
  <figcaption>Rain on a tin roof</figcaption>
  <audio controls>
    <source src="rain.mp3" type="audio/mpeg">
    <source src="rain.ogg" type="audio/ogg">
    Your browser cannot play this sound.
  </audio>
</figure>

Press show my page to see it here.

<source> is empty, so it has no closing tag.