본문으로 건너뛰기

<audio> Tags in HTML

<audio> Tags

Let's delve into the main attributes and usage of the <audio> tag to incorporate sound effects into web pages.


What is an <audio> tag?

The <audio> tag is used in HTML to play music files. It allows you to play your favorite songs, created sounds, or any audio on a web page.

For example, it can be used like this:


How to use audio tag
<audio controls>
<source src="your-audio.mp3" type="audio/mp3" />
Your browser does not support the audio tag.
</audio>
  • controls display the controllers that let you play, pause, and adjust the volume of the music.

  • The <source> tag specifies the location and type of the music file.


Key Points for the <audio> tag

  1. File Formats: Not all browsers support the same audio formats. Therefore, you should prepare your audio files in various formats.

  2. Alternative Text: The text written between the <source> tags will be displayed in browsers that do not support the audio tag. It is good to provide a simple explanation that informs the user about what the audio is.

  3. Consider File Size: Audio files can sometimes be large and may affect the loading time of web pages. It's best to use files that are as small as possible and, if necessary, compress them to minimize their impact on page load times.

다음 내용이 궁금하다면?

월 12,500원 PLUS 멤버십 가입 or 강의를 등록해 주세요!