HTML Audio

HTML provides a built-in element called `<audio>` that allows you to embed audio files directly into your web page. Here's an example of how you can use the `<audio>` element:

html
<audio src="audio-file.mp3" controls>
    Your browser does not support the audio element.
</audio>

In the example above, replace `"audio-file.mp3"` with the path to your audio file. The `src` attribute specifies the URL of the audio file you want to play. The `controls` attribute adds a set of playback controls to the audio player, such as a play/pause button, volume control, and timeline.

If the browser doesn't support the `<audio>` element or the specified audio file format, it will display the fallback content within the `<audio>` tags, which in this case is the text "Your browser does not support the audio element."

You can also add additional attributes to the `<audio>` element for more control over the playback, such as `autoplay` to automatically start playing the audio when the page loads, or `loop` to make the audio repeat indefinitely. Here's an example:


html
<audio src="audio-file.mp3" controls autoplay loop>
    Your browser does not support the audio element.
</audio>

You can customize the appearance and behavior of the audio player further using CSS or JavaScript if needed.



About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





 PreviousNext