Open In App

How to Create a Download Link in HTML?

Last Updated : 17 Nov, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

A download link allows users to download a specific file when they click on it. The download attribute in HTML is used to create a download link. Using the anchor tag we can create a download link in the HTML.

Using the <a> Anchor Tag

To create a download link in HTML, use the <a> tag with the download attribute. Set href to the file’s URL and add download="filename" to trigger a download when clicked.

Syntax

<a href="file.pdf" download="file.pdf">Download</a>
HTML
<h2>
    Creating a Download Link in HTML
</h2>

<!-- Using the a tag with href 
     and download attributes -->
<a href="button.png" download>
    Click Here to Download the Image
</a>

Output

Create-a-Download-Link-ezgifcom-optimize
Output | How To Create A Download Link In HTML

Next Article

Similar Reads