HTML | download Attribute

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 the original filename is used.

Syntax: 

<Element download="filename">

Uses: It is used in <a> and<area> Elements. 

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

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

html
<!DOCTYPE html>
<html>

<head>
    <title>HTML a download Attribute</title>
</head>

<body>
    <p>Click on image to download</p>
    <p>
        <a href="
https://media.w3wiki.net/wp-content/uploads/20190221234751/w3wiki-logo1.png" 
           download>
            <img src=
"https://media.w3wiki.net/wp-content/uploads/20190221234751/w3wiki-logo1.png"
                 alt="gfg" width="500" height="200" />
        </a>
    </p>

</body>

</html>

Output: 

Supported Browsers

  • Google Chrome: 14.0
  • Firefox: 20.0
  • Opera: 15.1

Contact Us