Open In App

HTML <a> download Attribute

Last Updated : 23 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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>GeeksforGeeks</h1>

    <h2>HTML a download Attribute</h2>

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

</html>

Output

HTML-a-download-Attribute

Supported Browsers

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

Next Article

Similar Reads