Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTML and audio.labels


May 04, 2021 HTML Reference Manual


Table of contents


HTML and audio.labels

The label is provided by HTML5 to play audio files.

Play sound:

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

Try it out . . .

Browser support

HTML and audio.labels HTML and audio.labels HTML and audio.labels HTML and audio.labels HTML and audio.labels

IE 9 Plus, Firefox, Opera, Chrome, and Safari all support the hashtag.

Note: IE 8 or earlier versions of IE browsers do not support the label.


Label definition and instructions for use

The label defines sound, such as music or other audio streams.

Currently, there are three file formats supported by the element: 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

Tip: The MIME-type for these 3 types of audio are:

Audio format MINE-type
MP3 audio/mpeg
Ogg audio/ogg
Wav audio/wav

The difference between HTML 4.01 and HTML5

The label is the new label for HTML5.


Tips and comments

Tip: Text content can be placed between the slt; audio and slt;/audio, and the text information will be displayed in browsers that do not support the label.


Property

New : The new property in HTML5.

属性 描述
autoplay New autoplay 如果出现该属性,则音频在就绪后马上播放。
controls New controls 如果出现该属性,则向用户显示音频控件(比如播放/暂停按钮)。
loop New loop 如果出现该属性,则每当音频结束时重新开始播放。
muted New muted 如果出现该属性,则音频输出为静音。
preload New auto
metadata
none
规定当网页加载时,音频是否默认被加载以及如何被加载。
src New URL 规定音频文件的 URL。

Global properties

The label supports the global properties of HTML.


The event property

The tag supports the event properties of HTML.

Related articles

JavaScript and HTML DOM Reference Manual: HTML DOM Audio Objects