The HTML download attribute
Quick answer
The HTML download attribute tells the browser to download the linked URL instead of navigating to it, optionally with a suggested filename. It is used on the <a> and <area> elements.
Overview
The download attribute tells the browser to download the linked URL instead of navigating to it, optionally with a suggested filename. It applies to the <a> and <area> elements.
A bare download keeps the original filename; download="2026-report.pdf" suggests a new one. It works for same-origin URLs and for blob:/data: URLs; for cross-origin URLs browsers ignore the attribute and simply navigate, unless the server opts in with a Content-Disposition header.
Syntax
<a href="/report.pdf" download>Download</a>
Values
| Value |
|---|
| Empty (use the resource's name), or a string giving a suggested filename. |
Example
<a href="/report.pdf" download>Download the guide (PDF)</a>
Best practices
- Write descriptive link text. Avoid "click here", which is meaningless out of context.
- When using
target="_blank", modern browsers addrel="noopener"for you, but set it explicitly for older ones. - Use rel values like
nofollow,noreferrerandcanonicaldeliberately for SEO and privacy. - Make sure links are distinguishable by more than color alone.
Frequently asked questions
What does the download attribute do?
Prompts the browser to download the linked file.
How do I open a link in a new tab?
Add
target="_blank". Pair it with rel="noopener" for security in older browsers.What does the rel attribute do on a link?
It states the relationship to the linked resource, for example
nofollow, noreferrer, stylesheet or canonical.