<audio>
tag with autoplay
, loop
, and muted
attributes.To add ambient background music that autoplays and loops on a Webflow homepage, you must work within browser autoplay policies and Webflow’s capabilities.
Since Webflow doesn't have a native audio player element with autoplay and loop, you’ll use a custom embed block.
<audio autoplay loop playsinline muted id="bg-music"> <source src="YOUR_AUDIO_URL_HERE" type="audio/mpeg"> </audio>
YOUR_AUDIO_URL_HERE
with your uploaded audio file’s URL.Most browsers block autoplay with sound. Here are workarounds:
The muted
attribute allows autoplay but no audio will play until unmuted. You’ll need JavaScript to unmute after user interaction.
Add a Start button or “Tap to enter site” that, when clicked, unmutes the audio:
Add a button with an ID e.g., start-audio
.
Add this in the Before
section under Page Settings → Custom Code:
document.getElementById("start-audio").addEventListener("click", function() { var audio = document.getElementById("bg-music"); audio.muted = false; audio.play(); });
To keep the player running silently in the background:
style="display:none;"
to the tag, or wrap it in a hidden div.To add ambient background music on Webflow, upload the file, embed a hidden <audio>
tag with autoplay
and loop
, and unmute it using JavaScript after a required user interaction. Browsers block autoplay with audio unless muted or triggered by the user.