Overview
The download
attribute specifies that the target will be downloaded when a user clicks on the hyperlink.
The value of the attribute will be used for the name of the downloaded file. There are no limitations on allowed values. File extension (.html, .png, .jpg, .pdf, .txt, etc.) will be automatically detected by the browser and will be added to the downloaded file.
Note: download
is an optional attribute. However, this attribute is only used if the href
attribute is also set. If the attribute is not set, the original link filename is used.
Syntax & Example
<a href="example.html" download="file_name">
For instance, if you are going to download a file with a “New_File” filename, the download
attribute should read as follows
<a href="example.html" download="New_File">
The downloaded file will be named “New_File.html“