The download attribute on an <a> tag changes the URL from a redirect to a download link.
Clicking the link will download the resource specified in the href attribute.
An <a> element with a download attribute.
Clicking the image will download itself.
<a href="/img/html/html5.png" download>
<img src="/img/html/html5.png" alt="HTML5">
</a>
The <download attribute changes a link into a download link instead of navigational link.
With download enabled, the file referenced by the href attribute will be downloaded directly.
If a string value is provided on the download attribute, it will be used as the downloaded filename.
If not set, the original filename will be used.
Not all browsers support the download
attribute.
<a href="URL" download="filename" />
Value | Description |
---|---|
filename |
The name given to the downloaded file, for example, report.pdf. Note: filename is optional. If not provided the downloaded file name is the href URL value. |
Note: An href value is required for download to work.
An <a> tag with a download attribute set to AnnualReport.pdf.
Clicking the link will download a pdf report by that name.
<a download="AnnualReport.pdf"
href="/media/sample.pdf">Download Report</a>
Here is when download support started for each browser:
Chrome
|
14.0 | Jan 2010 |
Firefox
|
20.0 | Apr 2013 |
IE/Edge
|
18.0 | Jan 2020 |
Opera
|
15.0 | May 2013 |
Safari
|
10.1 | Mar 2017 |
Back to <a>