HTML <audio> Tag
The HTML <audio>
tag is used to embed audio resources in HTML.
It allows you to play audio on your web page without the need for a third-party plugin.
The HTML <audio>
tag is used to embed audio resources in HTML.
It allows you to play audio on your web page without the need for a third-party plugin.
Here is an example of how to create an audio element in HTML:
<audio controls>
<source src="audio.mp3" type="audio/mp3">
Your browser does not support the audio tag.
</audio>
The controls
attribute adds playback controls to the audio element.
The <source>
element specifies the URL of the audio file and its MIME type.
The text Your browser does not support the audio tag
is displayed if the browser does not support the audio tag.
The <audio>
tag has several attributes that can be used to customize the behavior and appearance of the audio element. Here are some of the most commonly used audio attributes:
src
: Specifies the URL of the audio file.controls
: Adds playback controls to the audio element.autoplay
: Specifies that the audio should start playing automatically when the page loads.loop
: Specifies that the audio should play in a loop.muted
: Specifies that the audio should be muted by default.CSS can be used to style the <audio>
tag and its contents. Here is an example of how to style an audio element using CSS:
audio {
border: 5px solid black;
margin: 10px;
}
<audio>
tag can be used to play audio on a web page without the need for a third-party plugin.<audio>
tag can help to improve the user experience of a web page.<audio>
tag to index the structure and content of web pages.