HTML <a> download Attribute

The <a> download attribute is used to download the element when the user clicks on the hyperlink. It is used only when 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. 

Syntax

<a download="filename">

Attribute Values

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

Example: This example demonstrates the use of HTML <a> download attribute.

html
<!DOCTYPE html>
<html>

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

<body>
    <h1>w3wiki</h1>

    <h2>HTML a download Attribute</h2>

    <p><a href="button.png" download>
            Click Here to Download Image
    </a></p>
</body>

</html>

Output

Supported Browsers

  • Google Chrome 14
  • Edge 18
  • Firefox 20
  • Safari 10.1
  • Opera 15

Contact Us