How to make an image link download on click with HTML?

Spread the love

Sometimes, we want to make an image link download on click with HTML.

In this article, we’ll look at how to make an image link download on click with HTML.

How to make an image link download on click with HTML?

To make an image link download on click with HTML, we set the download attribute.

For instance, we write

<a download="custom-filename.jpg" href="/path/to/image" title="ImageName">
  <img alt="ImageName" src="/path/to/image" />
</a>

to set the download attribute to the file name of the downloaded file.

Then when we click on the link, the file at the href path will be downloaded.

Conclusion

To make an image link download on click with HTML, we set the download attribute.

Leave a Reply

Your email address will not be published.