How to add audio to a website

April 10, 2021
0 minute read

You’ve spent a lot of time mapping out a website for your small business customer. You’ve created a beautiful design with great photos, strategically deployed video — and you know what will make it better: the judicious use of sound. 


Sound can be an excellent way to stand out from the competition, help visitors remember information (you know all of those brand jingles in your head?), and build an emotional connection with a brand. Audio can even help with SEO rankings when used in the right way.


In short, audio, when used properly, can be an important component of a website experience. 


Here are several options for embedding audio on a website no matter which CMS platform or website builder you are using.


1. Audio hosting


An easy way to embed audio on a website is by using a sound hosting site, such as SoundCloud or Mixcloud. All you need to do is upload the file and receive an HTML embed code. Then copy and paste the embed code into the web page’s code or WYSIWYG site editor. This works for most CMS platforms and website builders.


2. Add an audio widget on Duda


Duda’s highly flexible website builder platform features numerous special tools that make it super easy to add audio to a website while retaining control over how it looks and functions. First, follow the steps above to add the audio file to a sound hosting site. Then, to add it to your web page, select the audio widget from the menu and add the link to the audio file.


With Duda, you can set the layout, play icon, and sizing options using the Design Editor.


To access the design editor:


  • Right-click the widget, and click Edit Design.
  • If you are using Mixcloud, you have layout, thumbnail display, light/dark color scheme, and sizing options.
  • If you are using SoundCloud, you have layout, play icon color, and sizing options.


3. Use HTML5


You can code audio into your website with the HTML5 <audio> element. When you code it in with the <audio> command and source attribute (src), the default is the browser’s audio default settings. Or you can define some elements of how the audio will play, such as telling it to autoplay or play muted so the user can choose to turn on sound.


Here’s an example from W3Schools:


HTML

 

<audio controls autoplay>

  <source src="horse.ogg" type="audio/ogg">

  <source src="horse.mp3" type="audio/mpeg">

  Your browser does not support the audio element.

</audio>


Or muted:



HTML

 

<audio controls autoplay muted>

  <source src="horse.ogg" type="audio/ogg">

  <source src="horse.mp3" type="audio/mpeg">

  Your browser does not support the audio element.

</audio>


The text between the audio tags will only show if the browser doesn’t support the HTML5 audio element.


4. Add JavaScript


If you’re going to code a file into a website instead of using the Duda widget, we recommend using JavaScript in addition to HTML5. JavaScript provides more control to ensure that the audio is integrated into the site and acts as intended. For instance, it allows you to display play, pause, mute, and other control buttons. Other examples: You can set the default to sound off and allow sound to come on with an easy-to-find controller (this is highly recommended because sound can be distracting), and your script can even be programmed to play certain sounds in response to the user’s actions, such as during a quiz.


Here’s an example for adding a play button and pause controller and script to HTML code:


HTML

 

<audio controls id="music">

   <source src="mj.mp3" type="audio/mpeg">

   Your browser does not support the audio element.

</audio>


<p>Click the buttons to play or pause the music.</p>


<button onclick="play()" type="button">Play </button>

<button onclick="pause()" type="button">Pause</button>


<script>

   var myMusic=    
  document.getElementById("music");


   function play() {

      myMusic.play();

   }


   function pause() {

      myMusic.pause();

   }

</script>




Embedding audio on a website


When you’re ready to take a website to the next level, add some sound elements to it. Duda makes embedding audio simple. And if you need even more control, you can use JavaScript.


When to add audio to a website


Once you’ve understood how to add audio to a website, it’s incredibly important to know when to add audio to your site. There have been some horrific examples in the past, with audio often considered a bit of an afterthought proving more of a hindrance than a help.


However, audio can be hugely important in improving user experience these days, as long as you integrate it into your page at the right time. The best thing to do is consider the following:


Is it completely necessary?


First things first, do you need to add audio to a page? Consider if it is actually necessary and what effect it will have on your page. Does it boost the message or purpose you’re trying to achieve, and does it do so in the most effective manner?


You need to think about the search intent of the user and whether adding audio will add to that. For example, if someone is searching for a definition of what white labelling is, then they may just want a quick block of text to scan explaining. On the other hand, if someone is searching how white labelling works, then a more in-depth piece of audio or video would match that intent more. A good way to understand this is by analyzing the top performing pages on Google for a search term. If they are using audio, then there’s a good chance you should be too.


Consider the environment where people are browsing


Alongside the search intent, you should also consider where people are most likely to be browsing from, and on what device. Is your website more likely to be viewed in a quiet place such as an office, or is the page more likely to be viewed on the move via a mobile browser?


Understanding this can be another factor in when to use sound or not. By adding sound when it’s likely a browser is going to be somewhere quiet, may be more of an irritant for the user and others. Equally, if you believe that a browser will be using the audio in a busy space, for example an app in a food court, then you need to ensure that the sound will cut through the background noise in the environment. Understanding such context will help shape the audio you use and ultimately create a better user experience on your page.


Headshot of Renana Dar

Senior Content Writer, Duda.


Did you find this article interesting?


Thanks for the feedback!
Website mockups with error message
By Ilana Brudo November 13, 2025
Don't let AI-generated websites cause day-two headaches. Learn why agencies need governance and control, and how Duda's AI stack offers speed without the risks.
By Shawn Davis November 11, 2025
For small and medium-sized businesses (SMBs), conversion isn’t just about generating leads. It’s about helping potential customers act in the exact moment they’re ready. Traditional “contact us” forms and phone calls create unnecessary friction: the customer must wait, the business must respond, and momentum often disappears. A booking tool changes that dynamic. It lets customers confirm a time, get a confirmation, and move forward immediately. That single step, pivoting from inquiry to commitment, has a measurable effect. Research across multiple industries shows that websites offering real-time scheduling convert more visitors into paying customers. As AI search and zero-click search eat away at the amount of organic traffic being sent to SMB websites, developing high-quality conversion experiences has never been more important. From salons to consultants to local trades, every lost call or delayed email represents missed revenue. A booking tool captures intent before it fades.
A website with a 503 error
By Shawn Davis November 6, 2025
Learn how Jared Broussard's agency scaled client websites by switching from WordPress to Duda, saving time and costs while boosting efficiency and growth.
Show More

Latest posts