English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML: <audio> Tag

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.

Online example

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 ‹/›

Browser compatibility

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.

Definition and usage instructions of the tag

<audio> tag defines audio, such as music or other audio streams.
Currently, the <audio> element supports3types of file formats: MP3,WAV and OGG.

browserMP3WavOgg
Internet ExplorerYESNONO
ChromeYESYESYES
FirefoxYESYESYES
SafariYESYESNO
OperaYESYESYES

HTML 4.01 with HTML5differences

The <audio> tag is a part of HTML5new tag in

Tips and Notes

Note:<audio> and </ Any text between <audio> and

Attribute

New :HTML5 new attribute in

AttributeValueDescription
autoplayHTML5autoplayIf this attribute is present, the audio is played immediately after it is ready.
controlsHTML5controlsIf this attribute is present, the audio controls (such as play/pause buttons) are displayed to the user./Pause button).
loopHTML5loopIf this attribute is present, the audio will restart playing every time it ends.
mutedHTML5mutedIf this attribute is present, the audio output is silent.
preloadHTML5auto
metadata
none
Specifies whether the audio is loaded by default when the web page is loaded and how it is loaded.
srcHTML5URL Specifies the URL of the audio file.

Global Attributes

Support for <audio> tag Global Attributes of HTML.

Event Attributes

Support for <audio> tag HTML Event Attributes.