If the HTML audio tag is not working on your webpage, the problem is rarely the tag itself. Format support, autoplay policies, file paths, and CORS rules are the usual culprits — and each one has a straightforward fix.
The HTML audio tag is not working — you’ve added the tag, pointed it at your audio file, opened the browser, and nothing plays. No sound, no player controls, sometimes not even an error. Just silence.
This is one of those problems where your code can be completely correct and still fail, because audio on the web involves browser support rules, file format compatibility, autoplay restrictions, and server configuration — none of which have anything to do with whether your HTML is valid. This guide covers every real cause and exactly how to fix each one.
1. Start Here: Basic audio tag syntax
Before diagnosing anything, confirm your baseline HTML is correct. Here’s a complete, working audio tag:
|
1 2 3 4 5 6 |
<audio controls> <source src="audio/song.mp3" type="audio/mpeg"> <source src="audio/song.ogg" type="audio/ogg"> <!-- Fallback message for very old browsers --> Your browser does not support the audio element. </audio> |
Key things in this example worth noting:
- The
controlsattribute shows the play/pause/volume UI — without it, nothing renders visibly - Two
<source>tags provide fallback formats — the browser picks the first one it supports - The
typeattribute tells the browser the file format without downloading it first
If your code doesn’t look like this, start here. If it does, read on — the issue is something else.
2. Very Common: Unsupported audio format
Different browsers support different audio formats. If you only provide one format and the user’s browser doesn’t support it, the audio tag will silently fail — no error, just nothing.
Here’s the current format support across major browsers:
-
.mp3
? Chrome
? Firefox
? Safari
? Edge
Best universal choice -
.ogg
? Chrome
? Firefox
? Safari
? Edge
Good fallback -
.wav
? Chrome
? Firefox
? Safari
? Edge
Large file size -
.aac
? Chrome
? Firefox*
? Safari
? Edge
Good for Safari -
.webm
? Chrome
? Firefox
? Safari
? Edge
Modern, small size -
.flac
? Chrome
? Firefox
? Safari
? Edge
Lossless, large
Best Practice
Always provide at least two formats — MP3 as the primary (widest support) and OGG as a fallback. Safari users also benefit from AAC. The browser automatically picks the first format it can play.
Wrong — single format, no fallback
|
1 2 |
<audio controls src="song.ogg"></audio> <!-- Safari doesn't support OGG — silent failure --> |
Correct — multiple formats for all browsers
|
1 2 3 4 5 |
<audio controls> <source src="song.mp3" type="audio/mpeg"> <source src="song.ogg" type="audio/ogg"> <source src="song.aac" type="audio/aac"> </audio> |
3. Wrong file path
A wrong file path produces a completely silent, empty-looking audio player. The browser won’t throw a visible error on the page — it just loads nothing. Open the browser console (F12 ? Console) and you’ll likely see a 404 error if this is the problem.
Common path mistakes
|
1 2 3 4 |
<!-- File is in: /audio/bg-music.mp3 --> <source src="audio/BG-Music.mp3"> <!-- Wrong case --> <source src="sounds/bg-music.mp3"> <!-- Wrong folder --> <source src="/audio/bg-music.mp3"> <!-- Leading slash may cause issues locally --> |
Case Sensitivity Warning
File paths on Linux servers (where most websites are hosted) are case-sensitive. Music.mp3 and music.mp3 are different files. This works on your Windows machine locally, then breaks silently when you upload to the server.
To verify the path is correct, paste the full URL to your audio file directly into the browser address bar. If it downloads or plays, the path is fine. If you get a 404, the path is wrong.
4. Very Common: Autoplay is blocked by the browser
Since around 2018, every major browser blocks audio autoplay by default unless the user has already interacted with the page. If you’re trying to play audio automatically without a user clicking anything, it will be silently blocked.
This will be blocked on page load
|
1 |
<audio autoplay src="music.mp3"></audio> |
The browser console will show something like:
Console Error
Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.
The fix depends on what you actually need:
Option 1 — Let the user trigger playback
|
1 2 3 4 |
<audio id="myAudio" src="music.mp3"></audio> <button onclick="document.getElementById('myAudio').play()"> Play </button> |
Option 2 — Muted autoplay (browsers allow this)
|
1 2 |
<audio autoplay muted loop src="ambient.mp3"></audio> <!-- Muted autoplay is allowed; unmute after user interaction --> |
Browsers enforce autoplay restrictions to prevent sites from blasting audio at users without consent. This isn’t a bug you can override — it’s deliberate browser policy, and working with it (not around it) gives you a better user experience anyway.
5. Missing controls attribute — the player is invisible
This is one of the most common beginner mistakes. Without the controls attribute, the audio element renders with zero visible size. The audio might actually be loading correctly — you just can’t see or interact with the player.
No controls — nothing visible on the page
|
1 |
<audio src="song.mp3"></audio> |
With controls — browser renders the player UI
|
1 |
<audio controls src="song.mp3"></audio> |
If you’re building a custom player with JavaScript and intentionally hiding the default controls, make sure your custom play/pause buttons are correctly wired to the audio element’s .play() and .pause() methods.
6. CORS errors when loading audio from another server
If your audio file is hosted on a different domain than your webpage — a CDN, a cloud storage bucket, or another server — you may hit a Cross-Origin Resource Sharing (CORS) error.
The browser will block the audio from loading unless the audio server explicitly allows it.
In the browser console this looks like:
CORS Error
Access to audio at 'https://cdn.example.com/song.mp3' from origin 'https://mysite.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
The fix is on the server side, not in your HTML. The audio server needs to send this response header:
|
1 2 3 |
Access-Control-Allow-Origin: * # Or more restrictively: Access-Control-Allow-Origin: https://yoursite.com |
If you control the server, add that header. If you’re using cloud storage:
- AWS S3 — add a CORS configuration in the bucket settings
- Google Cloud Storage — set CORS via
gsutil cors set - Cloudflare — configure CORS headers in Transform Rules
If you don’t control the audio server, you’ll need to host the file somewhere you do control, or proxy it through your own server.
7. Corrupt or incomplete audio file
Sometimes the file itself is the problem. A partially uploaded file, a bad export from an audio editor, or a download that got interrupted can produce a file that looks fine in your file explorer but won’t play in the browser.
To test this quickly: try opening the audio file directly in the browser by typing its URL into the address bar.
If it plays there but not in your <audio> tag, the issue is your HTML or server config. If it also fails in direct playback, the file is the problem.
Quick test
Open the audio file in VLC or another desktop player. If it plays fine there but not in the browser, the format might not be web-compatible (some encodings of MP3 use profiles that browsers reject). Re-export using a tool like Audacity or FFmpeg with standard web settings.
|
1 2 3 4 |
# Convert to browser-safe MP3 using FFmpeg ffmpeg -i input.mp3 -codec:a libmp3lame -qscale:a 2 output.mp3 # Convert to OGG ffmpeg -i input.mp3 -codec:a libvorbis -q:a 4 output.ogg |
8. Works locally, breaks on the live server
Your audio plays perfectly when you open the HTML file on your own computer. You upload it and it stops working. A few specific things cause this:
| Cause | What happens | Fix |
|---|---|---|
| Case-sensitive paths | Works on Windows locally, breaks on Linux server | Match exact filename casing in your src attribute |
| Missing MIME type | Server sends audio file with wrong Content-Type | Configure MIME types on the server (see below) |
| File not uploaded | HTML uploaded but audio file wasn’t | Verify the file exists on the server via FTP/file manager |
| HTTPS mixed content | Page is HTTPS, audio src is HTTP — browser blocks it | Use HTTPS for all asset URLs |
9. Wrong MIME type from the server
Even if your audio file is perfectly valid, the browser may refuse to play it if the web server sends it with the wrong Content-Type header. This is a server configuration issue, not an HTML issue.
Check what MIME type your server is sending by opening DevTools ? Network tab ? click the audio file request ? look at the Content-Type response header. It should be:
| Format | Correct MIME Type |
|---|---|
| .mp3 | audio/mpeg |
| .ogg | audio/ogg |
| .wav | audio/wav |
| .aac | audio/aac |
| .webm | audio/webm |
| .flac | audio/flac |
To fix MIME types, add these to your server config:
Apache (.htaccess)
|
1 2 3 4 |
AddType audio/mpeg .mp3 AddType audio/ogg .ogg AddType audio/wav .wav AddType audio/aac .aac |
Nginx (nginx.conf)
|
1 2 3 4 5 6 |
types { audio/mpeg mp3; audio/ogg ogg; audio/wav wav; audio/aac aac; } |
Quick Troubleshooting Checklist
Go through these in order when your HTML audio tag is not working:
- 01Open the browser console (F12) — is there a 404, CORS error, or autoplay error? The console almost always tells you the real reason.
- 02Check the Network tab — does the audio file request go out? What HTTP status code does it return?
- 03Make sure the
controlsattribute is on the<audio>tag — without it nothing renders visually. - 04Provide multiple formats using
<source>tags — at minimum MP3 and OGG to cover all browsers. - 05Open the audio file URL directly in the browser address bar — if it 404s, your path is wrong.
- 06If using autoplay, check whether the browser’s autoplay policy is blocking it — try triggering play after a user click instead.
- 07Test in incognito mode and a different browser to rule out extensions and browser-specific quirks.
- 08If loading from another domain, check the server is sending
Access-Control-Allow-Originheaders. - 09Verify the server sends the correct
Content-TypeMIME type for your audio format.
Frequently Asked Questions (FAQS)
Q1. Why is my HTML audio tag not working even though the code looks correct?
Valid HTML doesn’t guarantee audio will play — the most common hidden causes are an unsupported file format, browser autoplay blocking, a wrong file path that returns a silent 404, or a CORS policy on the server. Open the browser console (F12) first; it almost always shows the real error.
Q2. Why does my audio play in Chrome but not in Safari?
Safari doesn’t support OGG or WebM audio formats. If you’re only providing an OGG file, Safari will silently skip it. Add an MP3 or AAC source as well — Safari supports both. Always use multiple <source> tags for cross-browser compatibility.
Q3. Why is autoplay not working in my audio tag?
All major browsers block audio autoplay unless the user has already interacted with the page. This is an intentional browser policy introduced around 2018.
The only exception is muted autoplay — <audio autoplay muted> is allowed. For unmuted audio, you need to trigger .play() in response to a user action like a button click.
Q4. My audio works locally but not after uploading — why?
The most common causes are case-sensitive file paths (Linux servers are case-sensitive, Windows is not), missing MIME type configuration on the server, or the audio file simply not being uploaded alongside the HTML.
Check the Network tab in DevTools to see whether the audio request returns a 200 or a 404.
Q5. What is the best audio format for HTML?
MP3 has the widest browser support and is the safest single choice. For best coverage across all browsers and devices, provide MP3 as the primary source and OGG as a fallback. If you need Safari compatibility with better quality, add AAC as a third option.
Q6. How do I play audio in HTML without the controls bar showing?
Simply omit the controls attribute and control playback via JavaScript using the .play() and .pause() methods on the audio element.
Remember that autoplay without user interaction will still be blocked by modern browsers regardless of whether controls are visible.
Wrapping up
When the HTML audio tag is not working, your first stop should always be the browser console — it takes ten seconds and will tell you the actual cause in most cases. A 404 means a path problem.
A CORS error means a server header problem. An autoplay error means a browser policy problem. Each is fixable once you know which one you’re dealing with.
The broader lesson here is the same one that shows up across web development: sometimes working code fails because of systems operating outside your HTML — browser policies, server configuration, file encoding.
Knowing those systems exist, and knowing where to look when they interfere, is what separates someone who debugs confidently from someone who stares at valid code and wonders why nothing works.
