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

Conteúdo do Curso

HTML Essentials

Audio

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

css

index

js

index

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?

Selecione a resposta correta

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

Selecione a resposta correta

Tudo estava claro?

Seção 3. Capítulo 3
We're sorry to hear that something went wrong. What happened?
some-alt