TRENDING TOPICS

×

<audio> tag in HTML5

An <audio> tag is a new HTML tag in HTML5. If you want to use an audio in your HTML webpage, it's very easy by HTML5 <audio> tag because the <audio> tag is use for enable sound file in HTML5.

Before HTML5, audio files could only be played in a browser with a plug-in (like flash). BUT The HTML5 <audio> element specifies a standard way to embed audio in a web page.

Audio Format Types

Based on audio format we can derive 3 types of value for type attribute in HTML Audio.

Supported audio formats: MP3, Wav, and Ogg in HTML5:

  • MP3 → audio/mpeg
  • Wav → audio/wav
  • Ogg → audio/ogg

<audio> tag syntax

Result

There is some controls attribute, we can use in audio tag; for example - autoplay, loop, muted, preload, etc. Preload attribute has three different properties like auto, metadata, and none.

  • Autoplay: Autoplay attribute play the audio, when the browser load the web page. It automatically plays the audio.
  • Loop: Loop attribute is used to automatic repetition of audio file playing in web page. We just have to define loop attribute in HTML Audio tag.
  • Muted: If we want to predefined muted audio in our web page then in this condition we can use muted attribute of HTML Audio control.
  • Preload: Preload attribute provide us control how we want to load audio file means audio file will be download automatically or after permission or it will not be download.

<audio> Tag Browser Support

Element Chrome Edge Firefox Safari Opera
<audio> Yes Yes Yes Yes Yes
version 4.0 9.0 3.5 4.0 10.5

<audio> Formate Browser Support

Mp3 file formate is very flexible to use in HTML because Mp3 formate support almost all browsers.

Element Chrome Edge Firefox Safari Opera Mobile
mp3 Yes Yes Yes Yes Yes Yes
Wav Yes No Yes Yes Yes Yes
Ogg Yes No Yes No Yes Yes

Global Attributes

Event Attributes

Advertise With Us

We offer sponsored posts and guest posts with do-follow links, back-links, and other advertising services, To advertise email us at "advertise@gdatamart.com"

© 2021 GDATAMART.COM (All Rights Reserved)