HTML Audio

 

HTML Audio – How to Add Sound to a Web Page

The HTML <audio> tag is used to place html audio files, such as music, within HTML documents. The HTML <audio> tag was first introduced in HTML5.

Prior to HTML5, audio files could only be played by utilizing a plugin, such as Flash. There wasn’t a widely used method for playing sound files.

 

Audio can be placed within HTML pages using the following method:

HTML5 <audio> Element

Using the HTML5 <audio> tag will enable you to specify sound within an HTML document, including streaming audio and music. This provides a great way to enable your visitors to listen to a tutorial, a seminar, music or whatever you’d like.


The new HTML5 Audio tag provides a basic standard for playing audio files within web browsers. The HTML code will look something like this:

<audio control>
<source src="filename.ogg" type="audio/ogg">
<source src="filename.mp3" type="audio/mpeg">
</audio>

HTML Audio – Using A Hyperlink

Hyperlinks may be used to link to an audio file within a web page. When clicked on, most web browsers will launch an application to enable the file to play.

Play the Audio

The HTML code will look something like this:

<a href="filename.mp3">Play the Audio</a>

 

If you’re looking for a simple way to include sound files within your web pages, try using the HTML Audio tag. It sure makes things a lot easier than using the old plug-ins.

This concludes the HTML Audio section. For additional tips and codes, visit the HTML Video section.