HTML Audio Tag

By Xah Lee. Date: . Last updated: .

Here's a example of embeded audio.

<audio src="i/s/test.m4a" controls></audio>

Here's what your browser shows.


HTML5 Audio Tag Attributes

Following are the most useful optional attributes.

auto, metadata, none. The default is auto, meaning browser decides.
Does not take any value
Does not take any value
Does not take any value

Note that the attributes {controls, autoplay, loop} do not take any value. Their existence or non-existence defines the behavior. It is incorrect to add a ="true" or ="false" in them. This type of attributes is called “boolean attributes”.

Test Your Browser

Here's different audio formats, using audio tag.

Macross Plus Pulse.opus
Bach WTC1 1 Martha Goldstein.ogg
raw file: bach_wtc1_p01.mid

Audio Formats Browser Support

audio format support 2018-11-14
.m4a (aka acc)yesyesyesyes

midi file is not supported by any browser, as of 2018-11-14.

HTML Video Audio

  1. HTML Video Tag
  2. HTML Audio Tag
Liket it? I spend 2 years writing this tutorial. Help me spread it. Tell your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS in Depth
  4. SVG
  5. Blog