HTML Audio Tag
HTML <audio> tag is used to embed audio content in a web page. It allows users to play sound files directly from the browser. The <audio> tag supports several attributes to control playback and specify different audio sources.
2024-08-21 15:13:17 - Sakala Code
HTML Audio Tag Syntax
<audio controls> <source src="audio.mp3" type="audio/mpeg"> <source src="audio.ogg" type="audio/ogg"> </audio>
HTML Audio Tag Attributes
- controls: Adds play, pause, and volume controls to the audio player.
- autoplay: Starts playing the audio as soon as it is ready (optional).
- loop: Repeats the audio indefinitely (optional).
- muted: Mutes the audio (optional).
- preload: Specifies if and how the audio file should be loaded when the page loads.
HTML Audio Tag With Example
<!DOCTYPE html> <html lang="en"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Audio Tag With Example</title> </head> <body> <h1>HTML Audio Tag With Example</h1> <audio controls> <source src="sample.mp3" type="audio/mpeg"> <source src="sample.ogg" type="audio/ogg"> </audio> </body> </html>