download attribute is an attribute on
<a> elements introduced in HTML5, which instructs browsers to download a URL instead of navigating to it.
As to the compatibility of
download attribute, it's supported by Chrome >=14 (2011-09), Firefox >=20 (2013-04), Edge 13 (2015-11), but has no support in IE or Safari (supported in Safari Technology Preview).
One more note on Edge: support for
download attribute in Edge is partial, i.e., the value (file name) set in
download attribute is not considered.
download attribute is set (whatever its value or no value), the link will get downloaded instead of being navigated to. This subjects to the same-origin policy in Firefox, but works in Chrome and Edge whether the target is of same-origin or not.
download attribute has a value, it's used as the pre-filled file name when saving the target. Though this functionality is bound to the same-origin policy. That is to say, if the link target is not of same-origin, the value of
download attribute (pre-filled file name) won't be considered.
If the provided file name in
download attribute contains disallowed characters for the operating system, it will get substituted (with
- in Chrome and
_ in Firefox). And if no valid file name can be constructed, Chrome defaults the file name to
In Chrome, even if a link is downloaded instead of being navigated to (though technically speaking, it's navigated under the hood), Chrome will give a warning in Developer Tools if
download attribute is not set. So always include this if link target is supposed to be downloaded, and make this a best practice. As this won't hurt for browsers do not support it anyway.
And the situation is similar for Edge, even if a link can be downloaded without
download attribute, Edge will give warnings in Developer Tools. So just include the
download attribute for files intended to be downloaded.