How to Create: Download Links
- Previous Page Shape
- Next Page Full Height Element
Learn how to create download links with HTML.
Download Links
You can use HTML's download
Attribute to specify that the target file will be downloaded when the user clicks on the hyperlink.
Example
<a href="w3logo.png" download> <img src="w3logo.png" alt="W3School"> </a>
Only when href
The attribute download
Attribute.
The value of this attribute will be the name of the downloaded file. 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.).
You can also specify download
The attribute specifies a value that will be the new filename for the downloaded file. If the value is omitted, the original filename will be used.
Example
For download
Specify a value for the attribute, which will be the new filename for the downloaded file ("w3logo.jpg" instead of "mycodew3cimage.jpg"):
Specify the value of the download attribute, which will be the new filename for the downloaded file ("w3logo.jpg" instead of "mycodew3cimage.jpg"):
<a href="w3logo.png" download="codew3c-logo"> <img src="w3logo.png" alt="W3School"> </a>
Browser Support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
14.0 | 13.0 | 20.0 | 10.1 | 15.0 |
- Previous Page Shape
- Next Page Full Height Element