Conteúdo do Curso
HTML Essentials
HTML Essentials
3. Images and Media
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 ascontrols
,autoplay
, andloop
; - 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 textYour browser does not support the audio element.
is displayed.
index
index
index
Video Tutorial
Tudo estava claro?