HTML download Attribute
Description
The HTML download attribute is a feature designed for use within <a> (anchor) tags to instruct the browser to download the target of the link instead of navigating to it. This attribute is particularly useful when linking to resources that should be saved directly to the user's device, such as PDF documents, image files, or other multimedia content.
When the download attribute is present, the browser will download the resource linked by the <a> tag's href attribute, rather than navigating to it. Optionally, the download attribute can be assigned a value, which will be used as the default filename for the saved resource, giving web developers control over the naming of downloaded files.
This attribute enhances user experience and control, providing a straightforward way to distribute downloadable content directly through hyperlinks. It's important to note, however, that the download attribute only works for same-origin URLs, unless the resource being downloaded is a blob object or a data URI, thereby respecting the security considerations of modern web browsers.
Syntax
<tagname href="URL" download="filename" />
Values
- filenameThe name given to the downloaded file, for example, sunset.jpg. Note: filename is optional. If not provided the downloaded file name is the href URL value.
Example
Browser Support
The following information will show you the current browser support for the HTML download attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.
This attribute is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 29th March 2024
