WHAT'S NEW?
Loading...

How to insert audio/mp3 in webpage (HTML5)

In HTML5<audio> element is used to embed the audio files in a web page. To embed audio files in webpage we should use latest version of web browser.
HTML5 Audio Example


HTML5 Code to embed audio file in webpage.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<!DOCTYPE html> 
<html> 
<head> 
 <title> </title> 
</head> 
<body> 

<h1> Inserting Audio File in Webpage </h1> 
<audio controls="">
  <source src="music.mp3" type="audio/ogg"></source>
  <source src="music.mp3" type="audio/mpeg"></source>
Your browser does not support the audio element.
</audio> 

</body> 
</html> 

In the above code the controls attribute adds audio controls such as play, pause, and volume. The <source> element allws us to include audio files which the browser may choose from. The browser will use the first recognized format. Must of the browser supports MP3 audio files, so it is recommended to use the mp3 audio file. Also you can include WAB and OGG file format.
Note: If your browser does not support the <audio> element then it will display "Your browser does not support the audio element."on the screen.


You may Like 

 

0 comments:

Post a Comment