Categories
JavaScript Answers

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

Spread the love

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

For instance, we write

<a href="dummy.pdf" download="filename.pdf">download</a>

to add the download attribute and set it to the file name of the downloaded file to make the file download instead of opening it.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

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