Page 120 - Plus_V2.2_C7_Flipbook
P. 120
ADDING AUDIO
This feature of HTML5 allows us to embed/insert sound files into a web page. We can insert songs,
interviews, etc on our webpage. In HTML5, audio can inserted using <AUDIO> tag or element.
Attributes of Audio Tag
The <AUDIO> tag is a container tag which is used to play an audio file in HTML. We can use audio
files like .mp3, .ogg files inside this element. This tag should be used along with <source> tag which
specifies the audio source file. The two important attributes which should be used inside the <source>
tag are— src and type. The ‘controls’ attribute which should be used inside the audio tag adds audio
controls, like play, pause and volume.
For example,
Note: Before trying this code, make sure that you have an audio .mp3 file in the same folder where
this HTML code is being saved. If the audio file is not available in the same folder, HTML code will not
work.
<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE> Trying Audio tag</TITLE>
</HEAD>
<BODY>
<H1>Trying Audio Element</H1>
<audio controls>
<source src=song.mp3 type=audio/mp3>
Your browser does not support the audio element
</AUDIO>
</BODY>
</HTML>
The text that is written inside the <AUDIO> tag is displayed only when the audio format file is not
supported by the browser being used.
Output:
Using <audio> tag
118 Premium Edition-VII

