Breaking

Wednesday, May 1, 2019

HTML audio Tag

Example

Play a sound:
<audio controls>
  <source src="horse.ogg"type="audio/ogg">
  <source src="horse.mp3"type="audio/mpeg">
  Your browser does not support the audio tag.
</audio>
Try it Yourself »

Definition and Usage

The <audio> tag defines sound, such as music or other audio streams.
Currently, there are 3 supported file formats for the <audio> element: MP3, WAV, and OGG:
BrowserMP3WAVOGG
Internet ExplorerYESNONO
ChromeYESYESYES
FirefoxYESYESYES
SafariYESYESNO
OperaYESYESYES

MIME Types for Audio Formats

FormatMIME-type
MP3audio/mpeg
OGGaudio/ogg
WAVaudio/wav


Browser Support

The numbers in the table specify the first browser version that fully supports the element.
Element
<audio>4.09.03.54.010.5

Differences Between HTML 4.01 and HTML5

The <audio> tag is new in HTML5.

Tips and Notes

Tip: Any text inside the between <audio> and </audio> will be displayed in browsers that do not support the <audio> tag.

Attributes

AttributeValueDescription
autoplayautoplaySpecifies that the audio will start playing as soon as it is ready
controlscontrolsSpecifies that audio controls should be displayed (such as a play/pause button etc)
looploopSpecifies that the audio will start over again, every time it is finished
mutedmutedSpecifies that the audio output should be muted
preloadauto
metadata
none
Specifies if and how the author thinks the audio should be loaded when the page loads
srcURLSpecifies the URL of the audio file

Global Attributes

The <audio> tag also supports the Global Attributes in HTML.

Event Attributes

The <audio> tag also supports the Event Attributes in HTML.

Related Pages

HTML DOM reference: HTML Audio/Video DOM Reference

Default CSS Settings

None.

No comments:

Post a Comment