Advertisements
Advertisements
Question
Explain how to insert an audio on a web page using <audio> tag. Give example to support your answer.
Explain
Advertisements
Solution
The <audio> tag in HTML5 embeds audio information on a webpage. It allows you to play audio files such as MP3, OGG, and WAV directly in your browser. Control playback with the <audio> element’s play, pause, and volume attributes.
Example:
<audio>
<source src="sample.mp3" type="audio/mpeg">
</audio>
The autoplay feature is used to start the audio file playing automatically whenever the webpage’s URL is loaded.
| Attributes | Description |
| Controls | Designates what controls to display with the audio player. |
| Src | Designates the URL of the audio file. |
| Loop | Designates that the audio file should continuously repeat. |
shaalaa.com
Is there an error in this question or solution?
