HTML Audio Tag
Here is a example of embeded audio.
<audio src="i/s/test.m4a" controls></audio>
Here is what your browser shows.
HTML5 Audio Tag Attributes
Following are the most useful optional attributes.
preload
-
auto
,metadata
,none
. The default isauto
, meaning browser decides. controls
- Does not take any value
autoplay
- Does not take any value
loop
- 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 is different audio formats, using audio tag.
Audio Formats Browser Support
format/browser | Chrome | Safari | Firefox | Edge |
---|---|---|---|---|
.m4a (aka acc) | yes | yes | yes | yes |
.mp3 | yes | yes | yes | yes |
.opus | yes | no | yes | yes |
.ogg | yes | no | yes | yes |
midi file is not supported by any browser, as of 2018-11-14.