To embed an audio file in an HTML document, you can use the <audio>
element. Here is an example of how to use the <audio>
element to embed an audio file in an HTML document:
<audio src="audiofile.mp3" controls>
Your browser does not support the audio element.
</audio>
In this example, the src
attribute specifies the location of the audio file, and the controls
attribute adds controls (such as a play button and volume slider) to the audio player.
You can also use the <audio>
element to specify multiple audio sources for different types of audio files. For example:
<audio controls>
<source src="audiofile.mp3" type="audio/mpeg">
<source src="audiofile.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
In this example, the first <source>
element specifies an MP3 audio file, and the second <source>
element specifies an OGG audio file. The browser will use the first audio file it supports.
I hope this helps! Let me know if you have any questions.