HTML: Audio Tag
what is Audio Tag
audio tag lets you embed a audio file.
Example
Here is what your browser shows.
Code
<audio src="i/s/test.m4a" controls></audio>
Attributes
Following are the most useful optional attributes.
controls-
show audio player controls.
Boolean attribute. Does not take any value.
if not on, the entire audio tag is invisible.
autoplay-
Boolean attribute. Does not take any value.
loop-
Boolean attribute. Does not take any value.
preload-
values is one of
auto→ default. means browser decides.metadatanone
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.
Audio tag is displayed inline by default
Audio tag is displayed inline by default. That is, it flows like text.
you can change to to block.
audio { display: block; }