# Force download links in HTML

> Learn how to force a file download in HTML by adding the download attribute to an a tag, so the browser saves the file instead of opening it in the tab.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2022-07-12 | Topics: [HTML](https://flaviocopes.com/tags/html/) | Canonical: https://flaviocopes.com/html-force-download-links/

I recently found out you can add the `download` attribute to an `a` tag:

```html
<a href="file.pdf" download>pdf</a>
```

and the browser forces the download even if the file could be loaded in the browser (like a PDF).

This only works for links on the same origin.
