To embed an image in an HTML document, you can use the <img>
element. The <img>
element is a self-closing tag, which means it does not have a closing tag. It requires the src
attribute, which specifies the source of the image, and the alt
attribute, which specifies an alternative text for the image.
Here is an example of how to use the <img>
element to embed an image in an HTML document:
<img src="image.jpg" alt="A description of the image">
In this example, the src
attribute specifies the source of the image (image.jpg
), and the alt
attribute specifies an alternative text for the image ("A description of the image").
You can also specify the size of the image using the width
and height
attributes. These attributes accept a value in pixels or as a percentage of the available space.
<img src="image.jpg" alt="A description of the image" width="200" height="100">
In this example, the width
attribute specifies the width of the image (200 pixels), and the height
attribute specifies the height of the image (100 pixels).
To embed audio in an HTML document, you can use the <audio>
element. The <audio>
element represents a sound or audio stream, and it should contain the src
attribute, which specifies the source of the audio.
Here is an example of how to use the <audio>
element to embed audio in an HTML document:
<audio src="audio.mp3"></audio>
In this example, the src
attribute specifies the source of the audio (audio.mp3
).
You can also use the <source>
element to specify multiple sources for the audio, in case the browser does not support the specified format.
<audio controls>
<source src="audio.mp3" type="audio/mpeg">
<source src="audio.ogg" type="audio/ogg">
Your browser does not support the audio element.
</
0 Comments