Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Audio | Images and Media
course content

Зміст курсу

HTML Essentials

AudioAudio

In HTML, we can embed audio and video content directly into the web pages using the <audio> and <video> tags, respectively. Let's discuss embedding audio first:

Embedding Audio

The <audio> tag embeds audio content into an HTML document. It allows you to play audio files directly within the browser.

Audio Attributes

  • controls: Adds standard audio controls, such as play, pause, and volume adjustment, to the player;
  • autoplay: Specifies whether the audio should start playing automatically when the page loads;
  • loop: Specifies whether the audio should loop continuously.

Example:

You may have noticed that we have only specified the characteristics of the audio player, but we have not mentioned where the audio is coming from. We need the <source> tag.

Source

The <source> tag is used inside the <audio> tag to specify the URL of the audio file and its attributes. We can use the src attribute to specify the URL of the audio file and the type attribute to specify the MIME type of the audio file.
Example:

In the example above:

  • The <audio> tag includes attributes such as controls, autoplay, and loop;
  • The <source> tags specify the source URLs of the audio files and their MIME types;
  • If the browser does not support the <audio> tag or the specified audio formats, the alternative text Your browser does not support the audio element. is displayed.
html

index.html

css

index.css

js

index.js

Commonly supported audio formats include MP3, Ogg, and WAV. Providing the audio in multiple formats is recommended to ensure compatibility across different browsers and devices.

Video Tutorial

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?

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

Виберіть правильну відповідь

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

Виберіть правильну відповідь

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

Секція 3. Розділ 3
course content

Зміст курсу

HTML Essentials

AudioAudio

In HTML, we can embed audio and video content directly into the web pages using the <audio> and <video> tags, respectively. Let's discuss embedding audio first:

Embedding Audio

The <audio> tag embeds audio content into an HTML document. It allows you to play audio files directly within the browser.

Audio Attributes

  • controls: Adds standard audio controls, such as play, pause, and volume adjustment, to the player;
  • autoplay: Specifies whether the audio should start playing automatically when the page loads;
  • loop: Specifies whether the audio should loop continuously.

Example:

You may have noticed that we have only specified the characteristics of the audio player, but we have not mentioned where the audio is coming from. We need the <source> tag.

Source

The <source> tag is used inside the <audio> tag to specify the URL of the audio file and its attributes. We can use the src attribute to specify the URL of the audio file and the type attribute to specify the MIME type of the audio file.
Example:

In the example above:

  • The <audio> tag includes attributes such as controls, autoplay, and loop;
  • The <source> tags specify the source URLs of the audio files and their MIME types;
  • If the browser does not support the <audio> tag or the specified audio formats, the alternative text Your browser does not support the audio element. is displayed.
html

index.html

css

index.css

js

index.js

Commonly supported audio formats include MP3, Ogg, and WAV. Providing the audio in multiple formats is recommended to ensure compatibility across different browsers and devices.

Video Tutorial

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?

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

Виберіть правильну відповідь

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

Виберіть правильну відповідь

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

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