Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

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

#

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>

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.

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>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides