Home / Learn HTML / HTML Audio

HTML Audio

The audio element plays sound. It works like video but has no picture.

Definition

The audio element plays sound: music, a podcast, a voice recording. Formats are MP3, WAV and Ogg. It works just like video: add controls and give one or more source files.

Tip:Never start sound automatically. It annoys people and browsers block it.

Theory in plain words

Audio playback<audio controls>Browser picks sourceDecodes the fileSound plays
Audio playback

What it is

The audio element plays sound files with a built-in player.

Why we use it

It lets you add podcasts, music and sound effects without extra software.

How it works

The browser shows a small player when controls is set and plays the first supported source.

Where it is used

  • Podcasts
  • Pronunciation in language lessons
  • Sound effects
Audio with controlsTry it Yourself
Source tagsTry it Yourself
Loop and mutedTry it Yourself
Play from a buttonTry it Yourself
VolumeTry it Yourself
Podcast style cardTry it Yourself
Preload noneTry it Yourself

Saves data until the person presses play.

Tell the user if audio is missingTry it Yourself
Play and pause buttonsTry it Yourself
Show the lengthTry it Yourself

Quick quiz

1. Which tag plays sound?

2. Which makes sound repeat?

3. Which attribute delays loading?

Common questions

Which tag plays sound?

<audio>. audio plays sound.

Which makes sound repeat?

loop. loop repeats forever.

Which attribute delays loading?

preload="none". Saves data until play.

My notes
Ask a question about this lesson