HTML <audio>タグ


サウンドファイルを再生します。

<audio controls>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
  Your browser does not support the audio tag.
</audio>

定義と使用法

タグは、<audio>音楽やその他のオーディオストリームなどのサウンドコンテンツをドキュメントに埋め込むために使用されます。

タグには、異なるオーディオソースを持つ<audio>1つ以上 のタグが含まれています。<source>ブラウザは、サポートする最初のソースを選択します。

<audio>タグとタグの間のテキストは、要素</audio> をサポートしていないブラウザでのみ表示されます。<audio>

HTMLでサポートされているオーディオ形式には、MP3、WAV、OGGの3つがあります。

オーディオフォーマットとブラウザのサポート

Browser MP3 WAV OGG
Edge / IE YES YES* YES*
Chrome YES YES YES
Firefox YES YES YES
Safari YES YES NO
Opera YES YES YES

* Edge79から


ヒントと注意

ヒント:ビデオファイルについては、タグを確認してください。 <video>



ブラウザのサポート

表の数字は、要素を完全にサポートする最初のブラウザバージョンを示しています。

Element
<audio> 4.0 9.0 3.5 4.0 11.5

属性

Attribute Value Description
autoplay autoplay Specifies that the audio will start playing as soon as it is ready
controls controls Specifies that audio controls should be displayed (such as a play/pause button etc)
loop loop Specifies that the audio will start over again, every time it is finished
muted muted Specifies that the audio output should be muted
preload auto
metadata
none
Specifies if and how the author thinks the audio should be loaded when the page loads
src URL Specifies the URL of the audio file

グローバル属性

この<audio>タグは、HTMLのグローバル属性もサポートしています。


イベント属性

この<audio>タグは、HTMLのイベント属性もサポートしています。


関連ページ

HTML DOMリファレンス:HTMLオーディオ/ビデオDOMリファレンス


デフォルトのCSS設定

なし。