Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

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

ParameterTypeDescription
downloadfile 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

  • <a> — A link to another page, a file or a place on the page.
  • href — The address an `<a>` link leads to or a `<link>` points at.
  • target — `target` chooses where a link opens; `rel` describes the relation to the linked page.

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.

Thanks for reading!

Donate to the site — we work hard for you.