HTML unsupported media fallback allows users to view your content if a video or audio file cannot be played. Provide alternative media files, include download and transcript links outside of the video player, and implement a JavaScript error message to inform users when they have encountered an issue playing back media. Text inside the <video> element alone does not cover every playback failure.
Chances are good that many viewers have experienced this situation: the controls load, but there is nothing (a blank space) displayed. Although the browser understands the video element, it may be unable to decode your media file. The URL used may be returning a login page instead of your video. Users need somewhere to turn to when their experience results in the above outcome.

What HTML unsupported media fallback covers
In total, there are three areas that you want to provide backup for. An additional file provides the browser with an alternative format to attempt to decode. Using text within the media element provides a means for browsers that do not yet support the media element to display something. Providing visible download and transcript links, along with a JavaScript error message, gives users somewhere to go when playback fails.
The WHATWG documentation on video, which describes the fallback content for the video element, states that the purpose of providing fallback content is to allow older browsers lacking support for the video element to display some form of content. A modern browser failing to successfully play your MP4 will not render the paragraph contained in the fallback content.
Provide your download link and transcript link directly under the video player. By doing this, users who are experiencing a slow internet connection will have the option to select viewing a transcript prior to having to wait through a possible failure.
| Situation | Useful response |
|---|---|
| Browser cannot use the preferred media format | Offer a genuinely different compatible source |
| Browser does not implement the media element | Include fallback text inside the element |
| Every source fails to load | Show a message and keep alternatives visible |
| Visitor cannot access the audio or visuals | Provide appropriate captions, descriptions and a transcript |
HTML unsupported media fallback: a video example
Start with standard HTML. In this example, we’re listing WebM first and MP4 second. You will need to create two versions of your video. Simply changing the filename from “.webm” to “.mp4” does not convert your video.
<video id="lesson" controls playsinline preload="metadata"
width="960" height="540"
aria-describedby="media-status">
<source src="/media/lesson.webm" type="video/webm">
<source src="/media/lesson.mp4" type="video/mp4">
<track kind="captions" src="/media/lesson-en.vtt"
srclang="en" label="English" default>
<p>This browser does not support HTML video.
Use the links below instead.</p>
</video>
<p id="media-status" role="status"></p>
<p>
<a href="/media/lesson.mp4" download>Download the video (MP4)</a>
or <a href="/transcripts/lesson/">read the lesson transcript</a>.
</p>
Remove the example paths and insert your own file locations and document paths on your website. Be sure to create your transcript document. For an MP4 intended for a broad audience, H.264 video with AAC audio is a useful starting point. Test the final output on representative devices used by your audience.
A browser evaluates candidates based on the order listed. With accurate type hints, a browser can avoid trying formats that it does not support prior to attempting to download them. MP4 containers can hold different codecs. The extension on your file does not guarantee that playback will work.
Do not include src on the opening <video> tag if you are using child sources. Any URL located on the video element overrides any src values included in the source elements. Additionally, including ‘preload=”metadata”‘ is a suggestion: the browser determines how much data it wishes to retrieve.

HTML unsupported media fallback with JavaScript
Although HTML provides users with alternative choices to fall back on, JavaScript lets you add a notification when playback fails. While you may see an error icon in most browsers indicating a failure, it does little to explain what went wrong.
With multiple sources comes added complexity. Source failures do not bubble up as standard video errors. Therefore, listen for each source individually and the player itself. Failure of one candidate should not trigger a failure message while there are other candidates remaining.
const player = document.getElementById("lesson");
const status = document.getElementById("media-status");
const sources = [...player.querySelectorAll("source")];
const failed = new Set();
function showFailure() {
status.textContent =
"The video could not play. Try the download or transcript below.";
}
sources.forEach((source) => {
source.addEventListener("error", () => {
failed.add(source);
if (failed.size === sources.length) showFailure();
});
});
player.addEventListener("error", showFailure);
player.addEventListener("loadstart", () => {
failed.clear();
status.textContent = "";
});
player.addEventListener("loadedmetadata", () => {
status.textContent = "";
});
// Run once during setup, after the HTML and listeners exist.
player.load();
Load this script after your sample markup, or use a deferred external script. Calling load() restarts source selection after the event listeners are attached, so they can catch early failures.
Call it once upon initialization. Subsequent calls can disrupt ongoing playback and potentially reload requests. Since this example includes only a static list of two sources, applications using custom players that dynamically change their source lists will need to reset their own state. The message remains separate from the controls and does not move keyboard focus.
Additionally, if your application makes a call to play(), handle the rejected promise separately. Even though autoplay restrictions can block the call to play() regardless of compatibility with the file being requested, give your users an opportunity to click “play” before identifying incompatible formats.
Find the cause of unsupported media
To open developer tools and look at Network activity, navigate to the Network tab and locate your media request. What did your server actually send back? Look at both the body as well as status. A login screen or HTML error page returned with status code 200 is still not a video.
When the media element indicates a failure, inspect player.error. MDN documentation on MediaError.code identifies four general classes. Use them to isolate potential problems rather than assuming that a specific value represents a particular codec or hosting issue.
| Code | Meaning | Check next |
|---|---|---|
| 1: MEDIA_ERR_ABORTED | Fetching was aborted at the user’s request | Whether playback was cancelled or the source changed |
| 2: MEDIA_ERR_NETWORK | A network failure interrupted fetching | Connection, hosting and media request failures |
| 3: MEDIA_ERR_DECODE | Decoding failed after the resource seemed usable | File integrity and encoding settings |
| 4: MEDIA_ERR_SRC_NOT_SUPPORTED | The resource was unsuitable | Actual format, codec, response body and media type |
Check for missing files, expired signed URLs and login redirections. An HTTP media address may be blocked on an HTTPS page as mixed content. Check cross-origin policy separately where your player or captions require it. Adding crossorigin without matching server headers can introduce a failure.
For missing files, refer to our HTML5 video not found troubleshooting guide. When your file arrives but is not decodable, our guide to HTML5 video encoding errors will assist in evaluating the exported file.
Audio, transcripts and accessibility
Follow the same pattern as video: use <audio controls>, provide proper source files, and place downloads and transcripts adjacent to it. Remove any video-specific attributes like playsinline, width, height from your audio implementation.
Transcripts aid in accessibility even when playback works properly. Include speech, significant sound effects and speaker identification wherever necessary. For videos, describe important visual information not conveyed by audio. See W3C WAI guidance on transcripts for details on basic and descriptive transcripts.
Keep synchronised captions available for people watching the video as well. A transcript does not automatically replace synchronised captions or audio description, nor is a poster image an acceptable substitute for content.
Use descriptive language for links. Do not remove native control functionality unless you develop a valid replacement and thoroughly test its accessibility.
The download attribute asks the browser to perform a download for eligible URLs; however browser behavior and server headers influence the outcome. Downloading the same unsupported file does not guarantee it will play in another application.
Test your HTML unsupported media fallback

Test broken scenarios deliberately. Playing on your personal computer alone will never simulate what occurs when a visitor experiences different results.
- Break one of your URL source entries. Verify that your alternate entry will successfully play.
- Break both URL source entries. Verify that the failure message appears and both alternative links work.
- Create a bad copy of your media file intentionally. Verify that failure does not leave visitors without options.
- Turn off JavaScript. Verify that download and transcript remain shown.
- Try testing with a keyboard, a small width screen and at least one actual mobile device.
- Test caption loading separately. If you fail to load your caption document it may not block successful playback of video.
Verify testing occurs on production servers. Files loaded locally cannot expose every redirect, access restriction and response-header issue on your live servers. If you have a restricted Content Security Policy in place, move your JavaScript into an externally linked permitted resource file.
Common questions
Why does my fallback text not appear?
Your browser likely has supported media elements. The fallback content is designed specifically for older browsers without media support. Place alternatives outside of the media elements and handle source loading failures separately.
Will a second source always rescue playback?
No. A secondary source can only assist during initial candidate evaluation, but you cannot count on automatic recovery from decoding failures after playback has begun. Provide download and transcript alternatives.
Can CSS fix unsupported media?
CSS can style messages and resize players to fit a page. It cannot install codecs, fix corrupted files or resolve failed requests.
What is the safest starting point?
When implementing HTML unsupported media fallback, start with compatible encodes and links outside the media player. Add an informative error message and subsequently test the failure cases. A viewer who cannot watch should still know what to do next.
Join the discussion.