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 download Attribute

The download attribute on a link changes the URL from a redirect to a download link.

Elements that accept this attribute include <a>, and <area>.

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>

For additional details see our HTML a download Reference.


Using download

The download attribute turns 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

<tagname 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.


Elements that accept download

The following image-related elements accept the download attribute.

Elements Description
<a> Specifies an anchor link -- see example above
<area> Creates a clickable area inside an image map.

<area> with download

Three <area> tags with a download attribute.
Click on any of the areas and an image file will download.

Computer
<img src="/img/html/computer-map.png" alt="Computer" usemap="#computermap">

<map name="computermap">
  <area download shape="rect" coords="253,142,16,2" href="/img/html/area-monitor.png">
  <area download shape="rect" coords="262,218,0,156" href="/img/html/area-keyboard.png">
  <area download shape="circle" coords="267,234,22" href="/img/html/area-mouse.png">
</map>

For additional details see our HTML area download Reference.


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




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