HTML <오디오> 태그


예시

사운드 파일 재생:

<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>하나 이상의 태그가 포함되어 있습니다 . <source>브라우저는 지원하는 첫 번째 소스를 선택합니다.

<audio>와 태그 사이의 텍스트는 해당 요소 </audio> 를 지원하지 않는 브라우저에서만 표시됩니다 .<audio>

HTML에서 지원되는 오디오 형식은 MP3, WAV 및 OGG의 세 가지입니다.

오디오 형식 및 브라우저 지원

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

*엣지 79부터


팁 및 참고 사항

팁: 비디오 파일의 경우 태그를 확인하세요. <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 설정

없음.