How To Add Audio In HTML?

You are currently viewing How To Add Audio In HTML?

How To Add Audio In HTML?

To add audio in an HTML page, you can use the <audio> element.

Here is an example of how to use the <audio> element:

Copy code<audio controls>
  <source src="your-audio-file.mp3" type="audio/mpeg">
  <source src="your-audio-file.ogg" type="audio/ogg">
  Your browser does not support the audio element.
</audio>

The controls attribute adds audio controls, such as a play/pause button and a volume slider.

The <source> elements inside the <audio> element specify the audio files that the browser can choose from. The browser will use the first file type it supports. You can include multiple <source> elements to provide audio files in different formats, such as MP3 and Ogg Vorbis.

If the browser does not support the <audio> element or if it cannot play the specified audio file, the text between the <audio> and </audio> tags will be displayed.

Note: Not all browsers support all audio file formats. To ensure that your audio can be played on as many devices and browsers as possible, you should provide audio files in multiple formats.

if you need any help in wordpress development click here

This Post Has One Comment

Leave a Reply