HTML (Hypertext Markup Language) is a markup language used for creating web pages. Multimedia elements such as images, audio, and video can be added to an HTML document to enhance the user’s experience. Here are some HTML tags and attributes commonly used for adding multimedia elements:
- <img>: This tag is used to insert an image in an HTML document. The source (src) attribute specifies the URL of the image file. For example:
<img src="image.jpg" alt="An image" width="500" height="300">
- In this example, the image.jpg file is displayed with a width of 500 pixels and a height of 300 pixels. The alt attribute specifies alternative text that is displayed if the image cannot be loaded.
- <audio>: This tag is used to add audio to an HTML document. The src attribute specifies the URL of the audio file, and the controls attribute adds audio controls to the audio player. For example:
<audio src="audio.mp3" controls>
Your browser does not support the audio element.
</audio>
- In this example, the audio.mp3 file is played with audio controls that allow the user to play, pause, and adjust the volume of the audio.
- <video>: This tag is used to add video to an HTML document. The src attribute specifies the URL of the video file, and the controls attribute adds video controls to the video player. For example:
<video src="video.mp4" controls width="500" height="300">
Your browser does not support the video element.
</video>
- In this example, the video.mp4 file is played with video controls that allow the user to play, pause, and adjust the volume of the video. The width and height attributes specify the dimensions of the video player.
- <source>: This tag is used to specify alternative sources for multimedia elements. This is useful when different browsers support different multimedia formats. For example:
<video controls width="500" height="300">
<source src="video.mp4" type="video/mp4">
<source src="video.ogg" type="video/ogg">
Your browser does not support the video element.
</video>
In this example, the video.mp4 file is played if the browser supports the MP4 video format, and the video.ogg file is played if the browser supports the Ogg video format.
