English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Usage of <a> download attribute, online instances demonstrating how to use <a> download attribute, browser compatibility, syntax definition, and detailed introduction of its attribute values, etc.
Download the file when clicking the link (instead of navigating to the file):
<!doctype html> <html> <head> <title>Usage of the download attribute in html: <a> tag - Basic Tutorial(oldtoolbag.com)</title>/title> </head> <body> <p>Click w3codebox's logo for downloading images</p> <a href="/static/images/logo.png" download> <img src="/static/images/logo.png" alt="oldtoolbag.com" width="150" height="50"> </a> </body> </html>Test and see ‹/›
Note: Edge version12, IE, Safari 10(or earlier versions) or Opera version12(or earlier versions) do not support the download attribute.
The numbers in the table indicate the version number of the first browser that supports this attribute.
element | |||||
---|---|---|---|---|---|
download | 14.0 | 13.0 | 20.0 | 10.1 | 15.0 |
The download attribute specifies the target to be downloaded when the user clicks on the hyperlink.
This attribute is only used when the href attribute is set.
The value of this attribute will be the name of the downloaded file. There are no restrictions on the 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 will be used.
The download attribute is an HTML5New <a> tag attribute added in the middle.
<a download="filename">
Value | Description |
---|---|
filename | Specify the file name. |
Specify a value for the download attribute, which will be the new filename for the downloaded file ("w",3codeboxlogo.png” instead of “views.png”
<!doctype html> <html> <head> <title>Usage of the download attribute in html: <a> tag - Basic Tutorial(oldtoolbag.com)</title>/title> </head> <body> <a href="/static/images/logo.png" download="w3codeboxlogo> <img src="/run/html/views.png" alt="Views" width="300" height="200"> </a> <p>Please note that the filename of the downloaded file will be saved as “w3codeboxlogo.jpg” instead of “views.png”./p> </body> </html>Test and see ‹/›