Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Audio and Video | Working with Advanced Elements
HTML for Beginners
course content

Contenido del Curso

HTML for Beginners

HTML for Beginners

1. Understanding Basic Elements
2. Working with Semantic Elements, Multimedia Elements and Graphics
3. Working with Advanced Elements

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.

html

index

css

index

js

index

copy

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.

html

index

css

index

js

index

copy

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.

1. Which of the following attribute can be used with <audio> tag?
2. What are the correct attributes for the missing places?

Which of the following attribute can be used with

Selecciona la respuesta correcta

What are the correct attributes for the missing places?

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 3. Capítulo 4
We're sorry to hear that something went wrong. What happened?
some-alt