HTML <audio>Tag
Examples
Play sound:
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">Your browser does not support the audio element.</audio>
Try it Yourself »
Browser Support
The numbers in the table specify the first browser version that fully supports the tag.
| element | |||||
|---|---|---|---|---|---|
| <audio> | 4.0 | 9.0 | 3.5 | 4.0 | 10.5 |
Tag Definition and Usage Instructions
The <audio> tag defines sound, such as music or other audio streams.
Currently, the <audio> element supports three file formats: MP3, Wav, and Ogg.
| Browser | MP3 | Wav | Ogg |
|---|---|---|---|
| Internet Explorer | YES | NO | NO |
| Chrome | YES | YES | YES |
| Firefox | YES | YES | YES |
| Safari | YES | YES | NO |
| Opera | YES | YES | YES |
Differences between HTML 4.01 and HTML5
The <audio> tag is new in HTML5.
Tips and Notes
Tip:Text content can be placed between <audio> and </audio>, and this text will be displayed in browsers that do not support the <audio> tag.
Attributes
New: New attributes in HTML5.
| Attribute | Value | Description |
|---|---|---|
| autoplayNew | autoplay | If this attribute is present, the audio will play immediately after it is ready. |
| controlsNew | controls | If this attribute is present, audio controls will be displayed to the user (such as play/pause buttons). |
| loopNew | loop | If this attribute is present, the audio will start playing again every time it ends. |
| mutedNew | muted | If this attribute is present, the audio output will be muted. |
| preloadNew | auto metadata none |
Specifies whether and how the audio should be loaded when the page loads. |
| srcNew | URL | Specifies the URL of the audio file. |
Global Attributes
The <audio> tag supportsHTML Global Attributes。
Event Attributes
The <audio> tag supportsHTML Event Attributes。
Other Extensions