Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML

HTML

Example

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

The numbers in the table indicate the first browser version that supports the tag.

Element
4.0 9.0 3.5 4.0 10.5

Tag Definition and Usage Notes

Currently,

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


Tips and Notes

**Tip:** You can place text content between and the text information will be displayed in browsers that do not support the


property

New : New attributes in HTML5.

property Value Description
autoplayNew autoplay If this attribute is present, the audio will play as soon as it is ready.
controlsNew controls If this attribute is present, audio controls (such as play/pause buttons) are displayed to the user.
loopNew loop If this attribute is present, the audio will start over each time it finishes.
mutedNew muted If this attribute is present, the audio output is muted.
preloadNew auto
 metadata       

 none | Specifies当网页加载时,音频是否默认被加载以及如何被加载。 |

| srcNew | URL | Specifies the URL of the audio file. |

Global Attributes


Event attribute