download
Makes a link save the file instead of opening it, optionally under a different name.
Syntax
<a href="file.pdf" download="name.pdf">Download</a>Parameters
| Parameter | Type | Description |
|---|---|---|
| download | file name (optional) | Optional value: the suggested file name. Without a value the original name is used. |
Examples
The menu is saved as cafe-menu.pdf instead of opening in a browser tab:
<a href="/media/menu.pdf" download="cafe-menu.pdf">Download the menu (PDF)</a>Notes
Works only for files from the same site (or blob: and data: addresses created by scripts); for links to other domains the browser ignores it and just follows the link. Tell users what they get — the format and, ideally, the size — right in the link text.
See also
In the tutorial
- Links — The a tag and the href attribute, absolute and relative addresses, jumps within a page, a new tab, email and phone links.