English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The HTML <audio> element is used to represent audio content in a document. The <audio> element can contain multiple audio resources, which can be described using the src attribute or the <source> element; the browser will choose the most appropriate one to use. For browsers that do not support the <audio> element, the <audio> element can also be added to the document as unrecognized content by the browser.
Play sound:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Basic Tutorial Website(oldtoolbag.com)</title> </head> <body> <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> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
IE 9+Firefox, Opera, Chrome, and Safari all support the <audio> tag.
Note: IE 8 or earlier versions of IE browsers do not support the <audio> tag.
<audio> tag defines audio, such as music or other audio streams.
Currently, the <audio> element supports3types of 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 |
The <audio> tag is a part of HTML5new tag in
Note:<audio> and </ Any text between <audio> and
New :HTML5 new attribute in
Attribute | Value | Description |
---|---|---|
autoplayHTML5 | autoplay | If this attribute is present, the audio is played immediately after it is ready. |
controlsHTML5 | controls | If this attribute is present, the audio controls (such as play/pause buttons) are displayed to the user./Pause button). |
loopHTML5 | loop | If this attribute is present, the audio will restart playing every time it ends. |
mutedHTML5 | muted | If this attribute is present, the audio output is silent. |
preloadHTML5 | auto metadata none | Specifies whether the audio is loaded by default when the web page is loaded and how it is loaded. |
srcHTML5 | URL | Specifies the URL of the audio file. |
Support for <audio> tag Global Attributes of HTML.
Support for <audio> tag HTML Event Attributes.