Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Embedding Audio Files in HTML | Section
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
HTML Basics for Absolute Beginners (Sliced) - 1768407373666

bookEmbedding Audio Files in HTML

HTML allows you to add audio directly to a webpage using the <audio> tag.

Embedding Audio

The <audio> tag displays an audio player inside the browser.

Useful Audio Attributes

  • controls: shows play, pause, volume, etc;
  • autoplay: starts playing automatically;
  • loop: repeats the audio continuously
<audio controls autoplay loop>
  <!-- Source goes here -->
</audio>

Adding the Audio Source

The <source> tag inside <audio> tells the browser where the audio file is located and what format it is.

<audio controls autoplay loop>
  <source src="audio-url.mp3" type="audio/mpeg" />
  <source src="audio-url.ogg" type="audio/ogg" />
  Your browser does not support the audio element.
</audio>
  • <audio> defines the player and its behavior;
  • <source> provides audio file URLs and formats;
  • The fallback text appears if the browser can't play audio.
index.html

index.html

copy
Note
Note

Common audio formats: MP3, Ogg, WAV. Using more than one format increases browser compatibility.

1. Which tag is used to embed audio content into an HTML document?

2. Why is it recommended to provide the audio in multiple formats?

question mark

Which tag is used to embed audio content into an HTML document?

Select the correct answer

question mark

Why is it recommended to provide the audio in multiple formats?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 19

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

bookEmbedding Audio Files in HTML

Свайпніть щоб показати меню

HTML allows you to add audio directly to a webpage using the <audio> tag.

Embedding Audio

The <audio> tag displays an audio player inside the browser.

Useful Audio Attributes

  • controls: shows play, pause, volume, etc;
  • autoplay: starts playing automatically;
  • loop: repeats the audio continuously
<audio controls autoplay loop>
  <!-- Source goes here -->
</audio>

Adding the Audio Source

The <source> tag inside <audio> tells the browser where the audio file is located and what format it is.

<audio controls autoplay loop>
  <source src="audio-url.mp3" type="audio/mpeg" />
  <source src="audio-url.ogg" type="audio/ogg" />
  Your browser does not support the audio element.
</audio>
  • <audio> defines the player and its behavior;
  • <source> provides audio file URLs and formats;
  • The fallback text appears if the browser can't play audio.
index.html

index.html

copy
Note
Note

Common audio formats: MP3, Ogg, WAV. Using more than one format increases browser compatibility.

1. Which tag is used to embed audio content into an HTML document?

2. Why is it recommended to provide the audio in multiple formats?

question mark

Which tag is used to embed audio content into an HTML document?

Select the correct answer

question mark

Why is it recommended to provide the audio in multiple formats?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 19
some-alt