Open In App

How to create a download link with HTML ?

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

There are so many downloads from the websites daily, we can’t even count it’s beyond imagination. But as a programmer, you should know about creating a download link for yourself too so that when you need to add it to your website, it will be easy for you to add this feature. In this article, we will learn how to create a download link with html.

Download Link is a link that will download the specific file when the user clicks on it. Now, let’s talk about the attribute which will be used in the code while writing it. The “download” attribute is used to make the link downloadable. It will specify the target (pdf, zip, jpg, doc, etc) that will be downloaded only when the user clicks on the link. 

Note: The download attribute can be only used when the href attribute is set before.

Syntax:

<a href="NameOfFile.extension" download></a>

 

Example: This example describes how to create a downloadable link.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>Download Link</title>
</head>
  
<body>
    <h2>
        Demonstration for creating 
        a Download Link in HTML
    </h2>
  
    <!-- Using the <a> tag with href 
        and download attributes -->
    <a href="gfglogo.png" download>
        Click Here to download the image
    </a>
</body>
  
</html>


Output:

Supported Browsers:

  • Google Chrome
  • Firefox
  • Microsoft Edge
  • Safari
  • Opera

Last Updated : 20 Sep, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads