The download attribute on an <a> or <area> with an href tells the browser to download the linked resource instead of navigating to it. An optional value suggests the saved filename.
Without a value, the browser picks a name from Content-Disposition, the URL path, or the media type. With a value like guide.pdf, that name is suggested (slashes become underscores). Say in the link text that a download will start.
Baseline · Widely available.
Not deprecated and not experimental. Stable across modern browsers since about July 2015. Same-origin rules still limit when a custom filename is honored.
Same-origin only (plus blob: / data:).
Cross-origin href values usually ignore download and navigate instead. The remote server can still force a save via Content-Disposition.
Syntax
HTML Syntax
syntax.html
<a href="url" download>
Optional filename: download="report.pdf". Empty download or download="" still requests a download with a default name. In JavaScript: link.download = "report.pdf".
Values
Attribute Values
Optional filename string — presence alone is enough to request a download:
Value
Description
Try it
download (empty)
Download using a default name from headers, URL, or type
data: and blob: URLs work with download without a same-origin HTTP file.
How It Works
href holds a data: (or blob:) URL with the file bytes.
JavaScript sets HTMLAnchorElement.download to the filename.
Click saves that content under the suggested name.
Useful for exports, canvas images, and client-side reports.
Edge Cases & Pitfalls
Most surprises come from origin rules, HTTP headers, or unclear link text.
origin
Cross-origin ignores download
For other sites, the attribute is ignored and the browser navigates. Use same-origin files, or let the server send Content-Disposition: attachment.
headers
Content-Disposition can win
download overrides inline, but a header filename overrides the attribute’s suggested name.
name
Filename, not a path
Use report.pdf, not /files/report.pdf. Characters like / and \ become underscores.
a11y
Announce the download
Link text (or image alt) should say a file will download — unexpected saves confuse keyboard and screen-reader users.
ux
Browser settings vary
Users may get a prompt, auto-save, or open-in-app. You cannot fully control that from HTML alone.
Compatibility
Browser Support
download is an HTML attribute on links in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
download
Supported in modern Chrome, Firefox, Safari, and Edge. Custom filenames require same-origin (or blob:/data:) URLs; cross-origin behavior differs by browser.
96%Global support (approx.)
Google Chrome14+
Full support
Mozilla Firefox20+
Full support
Apple Safari10.1+
Full support
Microsoft Edge13+
Full support
Opera15+
Full support
Samsung InternetModern
Full support
Internet Explorer—
Not supported
downloadWidely supported
Bottom line: Safe for modern sites. Always plan for same-origin (or blob/data) when you need a reliable custom filename.
Remember
Key Takeaways
On <a> / <area>: download instead of navigate; optional filename.
Same-origin (plus blob: / data:) for the attribute to apply.
JS:link.download = "name.ext" for dynamic exports.
A11y: say in the link text that a file will download.
One line:download saves the linked file (same-origin) and can suggest the filename.
Frequently Asked Questions
On an a or area element with an href, download tells the browser to download the linked resource instead of navigating to it. An optional value suggests the saved filename.
Only a and area elements that have a valid href. It does not apply to button, img, or other tags by themselves.
Yes. Set download to a filename such as report.pdf. Use a name with an extension, not a full URL path. Slashes are turned into underscores.
No for the attribute itself. Browsers honor download for same-origin URLs, and for blob: and data: URLs. Cross-origin links usually navigate instead; the server may still force a download with Content-Disposition.
When download is honored, it overrides Content-Disposition: inline. But a Content-Disposition filename parameter overrides the name you put in the download attribute.
Yes. Use link.download = "filename.ext" on an HTMLAnchorElement. This pairs well with blob: and data: URLs for generated files.