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>.
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.
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.
<tagname 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.
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. |
Three <area> tags with a download attribute.
Click on any of the areas and an image file will download.
<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.
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 |