Getting Started with Coding
Book image
Explore Book Buy On Amazon

Providing a link so that visitors to your mobile site can download an audio file is the simplest option, especially compared to streaming audio. It's best to link to audio files rather than using the tag, which is more common on the desktop web.

Even some of the best-designed mobile sites that feature audio, including National Public Radio, link to audio files rather than insert them directly into a web page.

Linking to audio from a mobile site works the same way it does on a desktop website: You upload the audio file to a folder on your web server (or to the CDN that you use). Then you simply insert a link to the audio file in any web page in your site. A link to an audio file looks like this:

<a href="">Click to play my song!</a>

It's really not a good idea to use the command to play background music for a mobile web page. Similarly, using the or tag with the autostart=true command to automatically play an audio file upon page load is a no-no. These commands either cause an error or force the mobile user to download the entire audio file to see the contents of your page.

About This Article

This article can be found in the category: