HTML <a> download Attribute

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.

Example

#

A download attribute on an <a> tag.
Clicking the image will download itself.

<a href="/img/html/html5.png" download>
  <img src="/img/html/html5.png" alt="HTML5">
</a>

Using download

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.

Note: Not all browsers support the download attribute.


Syntax

<a href="URL" download="filename" />

Values

#

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.


More Examples

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>

Browser support

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

You may also like

 Back to <a>
Guides