Testing

HTML Download Attribute: Browser Support, Filename, CORS

HTML download attribute works in Chrome 14+, Edge 13+, Firefox 20+, Safari 10.1+, Opera 15+. See how to set a filename, why CORS blocks it, and known issues.

Author

Prince Dewani

May 6, 2026

The HTML download attribute is a WHATWG attribute on an anchor element that tells the browser to save the linked resource to disk instead of navigating to it. It works in Chrome 14+, Edge 13+, Firefox 20+, Safari 10.1+ on macOS, Safari 13+ on iOS, Opera 15+, Samsung Internet 4+, and Android Browser 4.4+; Internet Explorer never supports it.

This guide covers what the attribute is, the browsers that support it, how to use it, why it fails on cross-origin URLs, and the known issues.

What is the HTML download attribute?

The HTML download attribute is a boolean-or-string attribute defined by WHATWG on the anchor and area elements. When set, the browser treats the linked URL as a file to save rather than a page to open. The optional value supplies the suggested filename for the saved file.

Which browsers support the HTML download attribute?

The HTML download attribute is baseline widely available across every major desktop and mobile browser, with one notable hole: Internet Explorer never shipped support, and every browser blocks the filename hint on cross-origin URLs.

Loading browser compatibility data...

HTML download attribute compatibility in Chrome

Chrome supports the HTML download attribute from Chrome 14 on Windows, macOS, Linux, and ChromeOS, and from the same baseline on Chrome for Android. Chrome 65 tightened the cross-origin path: the filename hint is dropped for cross-origin URLs and some MIME types are blocked outright.

HTML download attribute compatibility in Edge

Edge supports the HTML download attribute from Edge 13 on the legacy EdgeHTML engine and from Edge 79 on the Chromium engine. The Chromium switch did not change the API surface, so any anchor with download keeps working when a tester upgrades from Edge Legacy.

HTML download attribute compatibility in Firefox

Firefox supports the HTML download attribute from Firefox 20 on Windows, macOS, and Linux, and from the same baseline on Firefox for Android. Firefox ignores the entire attribute on cross-origin URLs and navigates to the resource instead, which is stricter than Chrome's behavior.

HTML download attribute compatibility in Safari

Safari supports the HTML download attribute from Safari 10.1 on macOS and from Safari 13 on iOS and iPadOS. Older Safari builds ignored the attribute and navigated to the file. Safari honors the attribute only for same-origin, blob, and data URLs.

HTML download attribute compatibility in Opera

Opera supports the HTML download attribute from Opera 15 on desktop, the first Chromium-based release, and from Opera Mobile 80 on Android. The legacy Presto Opera 9 to 12.1 line did not support it. Opera Mini still does not support it because of its proxy rendering model.

HTML download attribute compatibility in Samsung Internet

Samsung Internet supports the HTML download attribute from Samsung Internet 4 on Android. The browser tracks Chromium, so every later Samsung Internet release inherits the same cross-origin tightening that Chrome 65 introduced.

HTML download attribute compatibility in Android Browser

The Android Browser and the system WebView support the HTML download attribute from Android 4.4 KitKat on, when the WebView switched to Chromium. Stock browsers on the older WebKit-based WebView ignored the attribute and opened the file in the page.

HTML download attribute compatibility in Internet Explorer

Internet Explorer never supports the HTML download attribute. IE 5.5 to IE 11 ignore the attribute and follow the link. Pages that need a save prompt on IE 10 and 11 fall back to navigator.msSaveOrOpenBlob. Microsoft has retired Internet Explorer, so prefer Edge for any modern test pass.

Note

Note: The HTML download attribute looks universal on a chart but breaks on cross-origin URLs, on Safari, and on Internet Explorer. Test it on real browsers and OS with TestMu AI. Try TestMu AI free!

How do you use the HTML download attribute?

Add the download attribute to any anchor that points at a file the user should save. The attribute can stand alone, or it can take a string that the browser uses as the suggested filename. Same-origin, blob, and data URLs are the only paths that get the filename hint.

  • Add the attribute to an anchor: Drop download into an a or area element that points at a file, for example <a href="/files/report.pdf" download>Download</a>. With no value, the browser picks a name from the URL or the Content-Disposition header.
  • Set a suggested filename: Assign a string, for example download="invoice-april.pdf". Forward and back slashes are converted to underscores; the browser strips any character the filesystem rejects.
  • Keep the file same-origin: Host the file on the same scheme, host, and port as the page. A cross-origin URL gets the filename dropped on Chrome and the entire attribute ignored on Firefox and Safari.
  • Wire up a JavaScript download: Build the bytes in the page, wrap them in a Blob, call URL.createObjectURL, and assign the result to the href of an anchor with the download attribute. Click the anchor and revoke the URL right after.
  • Verify the save dialog: Click the link in Chrome, Firefox, and Safari. The Save As prompt should show the filename you set. If it does not, check the Network tab for a Content-Disposition header that overrides the attribute.
// Same-origin download with the HTML download attribute.
// Paste into the DevTools console on a page you control.
const a = document.createElement("a");
a.href = "/files/report.pdf";
a.download = "monthly-report.pdf";
a.textContent = "Download monthly report";
document.body.appendChild(a);
a.click();

// Build a CSV in the page and save it without a server hop.
const blob = new Blob(["name,score\nPrince,42"], { type: "text/csv" });
const blobLink = document.createElement("a");
blobLink.href = URL.createObjectURL(blob);
blobLink.download = "scores.csv";
blobLink.click();
URL.revokeObjectURL(blobLink.href);
// Console output: a Save As prompt for monthly-report.pdf, then for scores.csv.

If the click opens the file in the browser instead of saving it, the page is sandboxed or the URL is cross-origin. Drop the iframe sandbox attribute or move the file to the same origin and re-run the test.

Why does the download attribute fail for cross-origin URLs?

The same-origin policy treats a download with a forced filename as a privileged action. A page on one origin should not be able to rewrite a file's name as it lands on the user's disk, since the new name could disguise a malicious payload as a trusted document.

Each browser ships its own enforcement of the rule:

  • Chrome and Edge: From Chrome 65 on, the filename hint is silently dropped for cross-origin URLs. The download still happens, but the saved file uses the server's name. Some MIME types are blocked outright in the navigation path.
  • Firefox: The attribute is ignored entirely on cross-origin URLs. The link navigates to the resource and the browser falls back to its default content disposition handling.
  • Safari: Same as Firefox. The attribute works only on same-origin, blob, and data URLs. A cross-origin link opens the file in a new tab.
  • The fix on the server: Send a Content-Disposition: attachment header with a filename parameter on the file's own origin. The header works across origins, across browsers, and inside Internet Explorer 10 and 11.
  • The fix in the page: Fetch the cross-origin file with CORS enabled, wrap the response in a Blob, call URL.createObjectURL, and assign the blob URL to an anchor with the download attribute. The blob URL is same-origin to the page.
...

What are the known issues with the HTML download attribute?

The HTML download attribute is a hint, not a contract. The browser, the user's settings, and the response headers all get a vote, and a page that ignores any one of them ships a broken download button.

  • Cross-origin filename is dropped: Chrome saves the file with the server's name, Firefox and Safari ignore the attribute and navigate. The reliable fix is a Content-Disposition: attachment header on the file's own origin.
  • Content-Disposition wins ties: A filename parameter in the response header takes priority over the attribute value. If a server sets the header, the page cannot override the saved filename from the client.
  • iOS Safari needs a user gesture: Programmatically clicking the anchor during page load is silently ignored. The click has to fire inside a touch or pointer event handler, otherwise the Save dialog never opens.
  • Internet Explorer ignores the attribute: IE 5.5 to IE 11 follow the href and open the file in the browser. The fallback is navigator.msSaveOrOpenBlob, which only exists on IE 10 and 11.
  • Slashes become underscores: A download value of "reports/2026/q2.pdf" is rewritten to "reports_2026_q2.pdf". Build the path on the server side instead of inside the attribute.
  • Sandboxed iframes break the click: An anchor inside an iframe with the sandbox attribute does not trigger a download unless allow-downloads is in the sandbox token list. Chrome 83 added the token; older releases never download from a sandbox.
  • Buttons do not work: The attribute is defined only on a and area. A button needs JavaScript that creates a temporary anchor, sets href and download, and calls click on it.

In my experience, the cross-origin filename trap is the one that ships to production unnoticed; a designer tests on localhost where everything is same-origin, the QA pass on a CDN-hosted asset silently saves the wrong filename, and nobody notices until a customer complains.

...

Citations

All HTML download attribute version numbers and behavior notes in this guide come from these primary sources:

Author

Prince Dewani is a Community Contributor at TestMu AI, where he manages content strategies around software testing, QA, and test automation. He is certified in Selenium, Cypress, Playwright, Appium, Automation Testing, and KaneAI. Prince has also presented academic research at the international conference PBCON-01. He further specializes in on-page SEO, bridging marketing with core testing technologies. On LinkedIn, he is followed by 4,300+ QA engineers, developers, DevOps experts, tech leaders, and AI-focused practitioners in the global testing community.

Open in ChatGPT Icon

Open in ChatGPT

Open in Claude Icon

Open in Claude

Open in Perplexity Icon

Open in Perplexity

Open in Grok Icon

Open in Grok

Open in Gemini AI Icon

Open in Gemini AI

Copied to Clipboard!
...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free

Frequently asked questions

Did you find this page helpful?

More Related Hubs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests