a download attribute
The download attribute on the a element:
- allows you to download a resource instead of navigating to it
- download is a specific attribute → can be applied ONLY on the next HTML5 elements: a, area
Warning: download attribute is currently supported in Firefox and Google Chrome
Examples
<a | attribute | = | "value(s)" | > | ... | <⁄a> | example |
---|---|---|---|---|---|---|---|
1. | download | = | resource name | <href="filetest.pdf" download> ... <⁄ >> < >href="filetest.pdf" download="a.pdf"> ... <⁄ >> | >
Video demonstration a download attribute
HTML5 a download attribute Tutorial
min | video details |
---|---|
00:06 | the download attribute on the a tag allows you to download a resource instead of navigating to it |
00:09 | this pdf file represents a resource |
00:19 | adding the download attribute to the 2nd a element |
00:28 | this link allows us to navigate to the testfile.pdf resource |
00:32 | testfile.pdf was opened in the browser window |
00:35 | this link allows us to download the resource |
00:50 | download attribute, values: - a name (your choice) for the file |
01:12 | - in Firefox browser: the file extension is required |
01:35 | - in Chrome browser: the file name is ignored: e.g. testfile.pdf instead of a.pdf |
01:49 | Browser tweaks: althought the download attribute is missing, we can still download the pdf file by changing the content type⁄action association in Firefox |
02:12 | the testfile.pdf resource was downloaded though the download attribute is absent on the a tag |