How to download a PDF file instead of opening them in the browser when clicked with HTML?

Spread the love

Sometimes, we want to download a PDF file instead of opening them in the browser when clicked with HTML.

In this article, we’ll look at how to download a PDF file instead of opening them in the browser when clicked with HTML.

How to download a PDF file instead of opening them in the browser when clicked with HTML?

To download a PDF file instead of opening them in the browser when clicked with HTML, we add the download attribute.

For instance, we write

<a href="http://link/to/file" download="FileName">Download it!</a>

to add the download attribute and set its value to the file name of the downloaded file.

Then the file will be downloaded when we click on the link.

Conclusion

To download a PDF file instead of opening them in the browser when clicked with HTML, we add the download attribute.

Leave a Reply

Your email address will not be published. Required fields are marked *