HTML download Attribute

HTML download Attribute: This attribute defines that the target will be downloaded when a user clicks on the hyperlink. It is used when the href attribute is set. While the name of the downloaded document is the value of the attribute. The values are allowed and have no restriction. And the browser can detected the correct file extension automatically and which is added to the file (.pdf, .txt, .html, .img, etc.).

HTML download Attribute

This attribute can be applied to <a>,<area> elements. The original filename is used when the value will be omitted.

Syntax: <a download = “filename”><a>

Browser Support

This attribute is supported by the following browsers :

  • Chrome
  • Firefox
  • Safari
  • Opera
  • Internet Explorer

Example: for <a> element

<!DOCTYPE html>
<html>
<body>
<p>Click on the Freshersnow logo to download the image:<p>
<a href="/images/image.jpg" download>
  <img src="/images/freshersnow.jpg" alt="freshersnow" width="104" height="142">
</a>
</body>
</html>

Output:

Click on the freshersnow logo to download

HTML a element

 

Example: for <area> element

<!DOCTYPE html>
<html>
<body>
<p>Click on the sun or on one of the planets to download its content.</p>
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="information_about_the_sun.htm" download>
  <area shape="circle" coords="90,58,3" alt="Mercury" href="merglobe.gif" download>
  <area shape="circle" coords="124,58,8" alt="Venus" href="information_about_the_planet_venus.txt" download>
</map>
</body>
</html>

Output:

HTML download attribute