<audio>


HTML <audio> Tag

Instance

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
</head>
<body>

<audio controls>
  <source src="horse.ogg" >
  <source src="horse.mp3" >
您的浏览器不支持 audio 元素。
</audio>

</body>
</html>

Run Example»

Click the "Run Instance" button to view the online instance


Browser support

1000.png

IE 9+, Firefox, Opera, Both Chrome and Safari support the <audio> tag.

Note: IE 8 or earlier versions of IE browsers do not support the <audio> tag.


Tag definition and usage instructions

<audio> tag defines sound, such as music or other audio streams.

Currently, the <audio> element supports three file formats: MP3, Wav, and Ogg.

##OperaYESYESYES
BrowserMP3WavOgg
Internet ExplorerYESNONO
ChromeYESYES YES
FirefoxYESYESYES
SafariYESYESNO


Differences between HTML 4.01 and HTML5

<audio> tag is New tags for HTML5.


Tips and Notes

Tips: You can place text content between <audio> and </audio>, and the text information will be Displayed in browsers that do not support the <audio> tag.


Attribute

New: New attribute in HTML5.

PropertiesValueDescriptionautoplayautoplayIf this attribute appears, the audio will be played as soon as it is ready. controlscontrolsIf present, displays audio controls (such as play/pause buttons) to the user ). looploopIf this attribute is present, playback will restart whenever the audio ends. mutedmutedIf this attribute is present, the audio output is muted. preloadautoSpecifies whether and how audio is loaded by default when the web page is loaded. src Specifies the URL of the audio file.

Global attributes

The<audio> tag supports HTML global attributes.


Event attributes

<audio> tag supports HTML event attributes.


New
New
New
New
New metadata
none
NewURL