HTML <a> download eigenschap
definitie en gebruik
download
eigenschap bepaalt het doel dat wordt gedownload wanneer de gebruiker op de hyperlink klikt (href-eigenschap bepaald in het bestand).
download
De opties van de eigenschap worden de nieuwe naam van het bestand na het downloaden. Elke waarde is toegestaan, de browser detecteert automatisch de juiste bestandsextensie en voegt deze toe aan het bestand (bijv. .img, .pdf, .txt, .html, enz.).
If the value is omitted, the original filename will be used.
Example
Example 1
Download the file when clicking the link (instead of navigating to the file):
<a href="/logo/w3logo-5.png" download>
Example 2
Specify the value of the download attribute, which will be the new filename for the downloaded file (for example, using "w3logo.jpg" instead of "mycodew3csimage.jpg"):
<a href="/logo/w3logo-5.png" download="w3logo">
Syntax
<a download="filename">
Attribute Value
Value | Description |
---|---|
filename | Optional. Specifies a new filename for the downloaded file. |
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* | 18.0 | 20.0* | 10.1 | 15.0 |
* Chrome 65+ and Firefox only support same-origin download links.