🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › audio
The Embed Audio element - HTML - MDN Web Docs - Mozilla
3 days ago - The HTML element is used to embed sound content in documents. It may contain one or more audio sources, represented using the src attribute or the element: the browser will choose the most suitable one. It can also be the destination for streamed media, using a MediaStream.
🌐
Computer Hope
computerhope.com › issues › ch000071.htm
How to Create a Link to Play a Sound File in HTML
January 6, 2025 - With HTML (HyperText Markup Language), linking a sound file using a href allows a browser to open and play an audio file if the viewer of your web page has properly configured their Internet browser.
🌐
W3Schools
w3schools.com › html › html5_audio.asp
HTML Audio
There are three supported audio formats: MP3, WAV, and OGG. The browser support for the different formats is: ... The HTML DOM defines methods, properties, and events for the <audio> element.
🌐
SitePoint
sitepoint.com › html & css
Link to audio - listen on same page - HTML & CSS - SitePoint Forums | Web Development & Design Community
May 4, 2021 - HTML & CSS · dafmorgan · May 4, 2021, 12:04am · 1 · Hi, Is it possible to use an image as a link to an audio file - and have the audio play while still on the page with the image? Currently when the image is clicked the player replaces the initial image/link page. Here’s the code I’m using. <a href="pathtomp3file.mp3"><img src="pathtoimage.jpg"></a> The audio is a message from the person in the image.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Structuring_content › HTML_video_and_audio
HTML video and audio - Learn web development | MDN
OVPs even usually offer ready-made code for embedding video/audio in your webpages; if you use that route, you can avoid some of the difficulties we discuss in this article. We'll be discussing this kind of service a bit more in the next article. The <video> element allows you to embed a video very easily. A really simple example looks like this: ... <video src="rabbit320.webm" controls> <p> Your browser doesn't support HTML video. Here is a <a href="rabbit320.webm">link to the video</a> instead.
🌐
W3Schools
w3schools.com › tags › att_audio_src.asp
HTML audio src Attribute
The src attribute specifies the location (URL) of the audio file.
🌐
W3Schools
w3schools.com › tags › tag_audio.asp
HTML audio tag
The <audio> tag also supports the Event Attributes in HTML.
🌐
DAISY
kb.daisy.org › publishing › docs › html › audio.html
Audio - Accessible Publishing Knowledge Base
Setting the controls attribute enables the native HTML controls by default. ... The aria-label attribute identifies the subject of audio clip. ... A link to a transcript is provided after the audio clip. <div> <audio src="audio/01.mp3" controls="controls" aria-label="Truman's fair deal"/> <a href="transcript01.html">Read the transcript</a> </div>
🌐
DotFactory
dofactory.com › html › audio › src
HTML audio src
In HTML, the src attribute on an tag specifies the URL or path of an audio file. This attribute is an alternative to a tag inside the audio element.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › html › html-audio
HTML Audio - GeeksforGeeks
July 23, 2025 - The <source> element specifies the audio file's URL and its MIME type. To learn more about the HTML audio autoplay attribute, click here Link
🌐
W3Schools
w3schools.com › tags › ref_av_dom.asp
HTML Audio/Video DOM Reference
The HTML5 DOM has methods, properties, and events for the <audio> and <video> elements.
🌐
GeeksforGeeks
geeksforgeeks.org › html › html-audio-src-attribute
HTML | &lt;audio&gt; src Attribute - GeeksforGeeks
July 15, 2022 - The HTML <audio> src attribute is used to specify the URL of the audio files. We should use the Mp3 file for play the audio in the Internet Explorer and Safari Browsers.
Top answer
1 of 8
130

Try this snippet

list.onclick = function(e) {
  e.preventDefault();

  var elm = e.target;
  var audio = document.getElementById('audio');

  var source = document.getElementById('audioSource');
  source.src = elm.getAttribute('data-value');

  audio.load(); //call this to just preload the audio without playing
  audio.play(); //call this to play the song right away
};
<ul style="list-style: none">
  <li>Audio Files
    <ul id="list">
      <li><a href="#" data-value="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.oga">Death_Becomes_Fur.oga</a></li>
      <li><a href="#" data-value="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.mp4">Death_Becomes_Fur.mp4</a></li>
      <li><a href="#" data-value="http://media.w3.org/2010/11/rrs006.oga">rrs006.oga</a></li>
      <li><a href="#" data-value="http://media.w3.org/2010/05/sound/sound_90.mp3">sound_90.mp3</a></li>
    </ul>
  </li>
</ul>

<audio id="audio" controls="controls">
  <source id="audioSource" src=""></source>
  Your browser does not support the audio format.
</audio>

JSFiddle http://jsfiddle.net/jm6ky/2/

2 of 8
5

Found this spec note for those trying to change the src of a source element. Especially useful for libs like React where audio.load() causes render loop.

..modifying a source element and its attribute when the element is already inserted in a video or audio element will have no effect. To change what is playing, just use the src attribute on the media element directly

<audio>
    <source src='./first-src'/>
</audio>

To change the src

<audio src='./second-src'/>
    <source src='./first-src'/>
</audio>
🌐
Raqueeb
raqueeb.com › blog › 2023 › 06 › 30 › html-audio-tag-explained
HTML Audio Tag Explained - Raqueeb.com
June 30, 2023 - <audio controls src="/assets/audios/test.mp3"> <a href="/assets/audios/test.mp3" download>Download audio</a> </audio> <!-- OR WITH SOURCE TAG --> <audio controls> <source src="/assets/audios/test.mp3" type="audio/mpeg" /> <source src="/assets/audios/test.ogg" type="audio/ogg" /> <a href="/assets/audios/test.mp3" download>Download audio</a> </audio> Anything in between the opening and closing audio tags except source tags will be shown if the browser doesn’t support audio embeds.
🌐
Tutorial Republic
tutorialrepublic.com › html-tutorial › html5-audio.php
How to Embed Audio in HTML5 - Tutorial Republic
You can make links to your audio files and play it by ticking on them. Let's try out the following example to understand how this basically works: ... The <object> element is used to embed different kinds of media files into an HTML document.
🌐
MiniTool MovieMaker
moviemaker.minitool.com › home › html audio full guide: how to add audio in html with attributes?
HTML Audio Review: How to Add Audio in HTML with Attributes?
October 18, 2024 - <a href=”audiofile.mp3″>Listen to audio file</a> The HTML audio element emits several events that you can use to trigger actions in your JavaScript code.
🌐
Stack Overflow
stackoverflow.com › questions › 69280059 › can-i-link-audio-thats-not-local-into-my-html-file
Can I link audio thats not local into my html file? - Stack Overflow
<a href="https://www.computerhope.com/jargon/m/example.mp3">Play sound file</a> The tag can create a media player as part of the web page. It allows the visitor to play, stop, pause, or download an audio file.