How to download file using anchor tag <a>

Solution 1:

In HTML5, in most browsers you can add a 'download' attribute to the a element.

for example:

<a href="http://www.example.com/index.html" download>Download</a>

Based on this question. How can I create download link in html?

Solution 2:

Use the "download" attribute:

<a href="jsplogin.jar" download>download</a>

Solution 3:

The download attribute didn't work for me, but this did:

<a href="myfile.csv" target="_blank">Download</a>

The opens a new tab but downloads the file and closes the tab once it realizes it's not a file type it should render. In my case it was a .csv, I did not test with .jar but i imagine you'd get the same result.