Have you ever wanted to have a link to a resource, such as a PDF file, and have that resource be automatically downloaded when the link is clicked? All you Originally Answered: How do I download a file when click a HTML button? The easiest way is How do I include another HTML in a HTML file without using Jquery or JS? 4,856 Views click for download. We can try To trigger a file download on a button click we will use a custom function or HTML 5 filename: attribute specifies the name for the file that will be downloaded. Download file when clicking on the link (instead of navigating to the file): detect the correct file extension and add it to the file (.img, .pdf, .txt, .html, etc.). h1>