Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML | download Attribute

Improve Article
Save Article
Like Article
  • Difficulty Level : Hard
  • Last Updated : 29 Apr, 2022
Improve Article
Save Article
Like Article

The HTML download Attribute is used to download the element when the user clicks on the hyperlink. It is used only when the href attribute is set. The downloaded file name will be the value of the attribute. The value of the attribute will be the name of the downloaded file. If the value is removed then original filename used.
Uses: It is used in <a> and<area> Element. 
Syntax: 

<Element download="filename">

Attribute Values: It contains single value filename which is optional. It specifies the new filename for the downloaded file.

The below example illustrates the use of download attribute in anchor Element. 
Example:

html




<!DOCTYPE html>
<html>
  <head>
    <title>HTML a download Attribute</title>
  </head>
 
  <body>
     
<p>Click on image to download</p>
 
 
     
<p>
      <a href="
        download
      >
        <img
          src=
          alt="gfg"
          width="500"
          height="200"
        />
      </a>
    </p>
 
  </body>
</html>

Output: 

Supported Browsers: The browsers supported by download Attribute are listed below: 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera

 

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!