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. For cross-origin URLs the filename hint is ignored for security.
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="https://codeshack.io/downloads/guide.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.