HTMLDownload Links

Download Links

By default, clicking a link to a PDF, image, or ZIP file usually just opens or previews it in the browser. The download attribute changes that—it tells the browser to save the file to disk instead, optionally under a filename you choose.
The download Attribute
Adding download (as a boolean attribute) to a link tells the browser to download the linked resource instead of navigating to or previewing it.

download-basic.html

HTML
<a href="/files/report.pdf" download>
  Download the report (PDF)
</a>
Suggesting a Filename
Give download a value to suggest a filename for the saved file, overriding whatever filename the URL implies.

download-filename.html

HTML
<a href="/downloads/q1-report-2026-03-14.pdf" download="quarterly-report.pdf">
  Download Q1 Report
</a>
It's only a suggestion
The download filename is only a suggestion. The browser, operating system, or the user can still choose a different filename when saving the file.
Browser Support Caveats
  • The download attribute generally works only for same-origin URLs (or resources served with appropriate CORS headers).

  • If the server sends a Content-Disposition: attachment header, the browser downloads the file even without the download attribute.

  • Some browsers may ignore download for file types they consider unsafe.

Cross-origin downloads
If you need users to download a file hosted on another domain (such as a CDN), the download attribute usually isn't enough. The server must return an appropriate Content-Disposition: attachment header, or you can proxy the file through your own server.
Linking to Non-HTML File Types
Links to PDFs, spreadsheets, images, ZIP archives, and other non-HTML resources work just like any other <a href="...">. The download attribute is optional and is only needed when you want to encourage downloading instead of previewing.

non-html-links.html

HTML
<!-- Browser will likely preview this PDF inline -->
<a href="/docs/manual.pdf">View the manual</a>

<!-- Browser will download this PDF -->
<a href="/docs/manual.pdf" download>Download the manual</a>

<!-- ZIP files are usually downloaded automatically -->
<a href="/assets/starter-kit.zip" download="starter-kit.zip">
  Download starter kit
</a>
Signal the file type and size
It's helpful to include the file type and size in the link text so users know what they're downloading, for example:
Download the manual (PDF, 2.4 MB)

signaling-file-info.html

HTML
<a href="/docs/manual.pdf" download>
  Download the manual <span class="file-meta">(PDF, 2.4 MB)</span>
</a>
Quick Reference

Attribute

Effect

download

Downloads the linked file instead of navigating to it (subject to browser and server restrictions).

download="name.ext"

Suggests a filename for the downloaded file.