Skip to content
Related Articles

Related Articles

Improve Article

How to create a download link with HTML ?

  • Last Updated : 20 Sep, 2021
Geek Week

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

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :