Conteúdo do Curso
HTML for Beginners
HTML for Beginners
Audio and Video
Audio
With HTML, you can embed audio and video files to your web page. We use the <audio>
tag to embed an audio file and the <source>
tag to provide a source of the audio file.
The <source>
tag comes with src
and type
attributes. For the src
attribute, you provide the file name (or link to the file), and for the type
attribute, you provide the file type.
index
index
index
Notice that we have added an attribute called controls
to the <audio>
tag. It doesn't take any value. This attribute is essential for the browser to use control elements such as the play pause button and volume icon.
If you want to replay the audio like a loop every time it ends, use the loop
attribute with the audio tag <audio controls loop>
.
Finally, the HTML <audio>
element supports three formats. Those are MP3, WAV, and OGG.
Video
Embedding videos is very similar to embedding audio. We will embed a video with the <video>
tag and the <source>
tag. We can define a width and height with video tags, although they are not mandatory.
index
index
index
There are several attributes you can use with video tags:
autoplay
: video will start playing as soon as it's ready;loop
: video will replay over and over again once it's finished;muted
: video will be played without audio.
Finally, HTML video supports three formats: MP4, WebM, and OGG.
Obrigado pelo seu feedback!