HTML CSS Javascript jQuery AJAX PHP Java MORE
Need a Website Or Web Application Or Any Help.Contact Us: +91 9437911966 (Whatsapp) Note: Paid Service

HTML Audio With Example

To play audio in HTML 5 we can used the <audio> element. <audio> element is introduced in HTML 5 before that audio files could only be played in a browser with a plug-in (like flash).

HTML 5 support three file format, these are MP3, OGG or WAV.

HTML Audio Attribute:

Autoplay: autoplay attribute is used to play an audio automatically .

<!DOCTYPE html>
<html>
<head>
	<title>audio autoplay</title>
</head>
<body>
   <audio src="" autoplay>Sorry your browser does not support embedding audios.</audio>
</body>
</html>

	

Run it yourself

Controls: The controls attribute is used to provide audio controls, like play, pause, and volume.

<!DOCTYPE html>
<html>
<head>
	<title>audio controls</title>
</head>
<body>
   <audio src="" controls>Sorry your browser does not support embedding audios.</audio>
</body>
</html>
	

Run it yourself

Loop: It is used to play an audio again and again.

<!DOCTYPE html>
<html>
<head>
	<title>audio autoplay loop</title>
</head>
<body>
   <audio src="" autoplay loop>Sorry your browser does not support embedding audios.</audio>
</body>
</html>
	

Run it yourself

Muted: To mute the audio muted attribute is used.

<!DOCTYPE html>
<html>
<head>
	<title>audio controls muted</title>
</head>
<body>
   <audio src="" controls muted>Sorry your browser does not support embedding audios.</audio>
</body>
</html>
	

Run it yourself

Src: To specify the path of audio src attribute is used.

<audio controls>
    <source src=".mp3" type="audio/mp3">
	<source src=".ogg" type="audio/ogg">
	Sorry your browser does not support embedding audios.
</audio>
	

Run it yourself