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"
Browser Support
IE 9 +, Firefox, Opera, Chrome and Safari support the <audio> tag.
Note: IE 8 or earlier versions of IE browser does not support the <audio> tag.
Tag definitions and instructions
<Audio> tag defines sound, such as music or other audio streams.
Currently, <audio> element supports three file formats: MP3, Wav, 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
<Audio> tag HTML5 is the new label.
Tips and Notes
Tip: You can place text in <audio> and </ audio> between, these text messages will be displayed in those who do not support the <audio> tag browser.
Attributes
New: HTML5 new property.
属性 | 值 | 描述 |
---|---|---|
autoplay New | autoplay | 如果出现该属性,则音频在就绪后马上播放。 |
controls New | controls | 如果出现该属性,则向用户显示音频控件(比如播放/暂停按钮)。 |
loop New | loop | 如果出现该属性,则每当音频结束时重新开始播放。 |
muted New | muted | 如果出现该属性,则音频输出为静音。 |
preload New | auto metadata none |
规定当网页加载时,音频是否默认被加载以及如何被加载。 |
src New | URL | 规定音频文件的 URL。 |
Global Properties
<audio> tag supports HTML global properties .
Event Properties
<audio> tag supports HTML event properties .