Download file when clicking on the link (instead of navigating to the file):
The download
attribute specifies that the target (the file specified in the href
attribute) will be downloaded when a user clicks on the hyperlink.
The optional value of the download
attribute will be the new name of the file after it is downloaded. There are no restrictions on allowed values, and the browser will automatically detect the correct file extension and add it to the file (.img, .pdf, .txt, .html, etc.).
If the value is omitted, the original filename is used.
The numbers in the table specify the first browser version that fully supports the attribute.
<a download="filename">
Value | Description |
---|---|
filename | Optional. Specifies the new filename for the downloaded file |
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<h1>The a download attribute</h1>
<p>Click on the image to download it:<p>
<a href="https://horje.com/avatar.png" download>
<img src="https://horje.com/avatar.png" alt="Horje" width="104" height="142">
</a>
<p><b>Note:</b> The download attribute is not supported in IE or Edge (prior version 18), or in Safari (prior version 10.1).</p>
</body>
</html>
Type: | Html |
Category: | Web Tutorial |
Sub Category: | HTML Tag |
Uploaded by: | Admin |