Create a download link with the HTML download attribute

In the hyperlink (a tag) of the HTML, if you don't use the download attribute to create a download link, user maybe open directly the file when they click on that hyperlink.

Usage:

 <a href="/download_file.txt" download>
  Download
 </a>

Copy this code

Note: The download attribute is only used if the href attribute is set.
The name of the file will automatically detect by the source file. If you want to change the name, you can set the name of the file by this way: download="file_name"

Demo: