Web design and digital-business ideas grounded in real tasks.

The HTML download attribute does not control every file link

A laptop showing a fictional document download link and a neutral browser save dialog, no recognisable branding.
AI-generated photographic illustration; not documentary photography.

A link contains the HTML download attribute, but clicking it opens the file in a browser tab. The attribute is not an unconditional command that overrides the resource’s origin, server response and browser behaviour.

MDN’s anchor-element reference explains that the attribute applies to same-origin URLs and to supported blob: and data: URLs. Server headers and browser choices also influence how a resource is handled and named.

Make a minimal test before changing the interface

For a file served from your own site, an illustrative link is <a href="/files/guide.pdf" download>Download the guide</a>. Test the actual response in the browsers you support. A working local example does not establish that an externally hosted document will behave the same way.

Check redirects as well as the original URL. The destination may be hosted elsewhere, require authentication or return an HTML page instead of the expected file. Inspect the response you receive rather than only the link markup you wrote.

Let the wording match the experience

If a document is expected to open for viewing, a label such as “View the guide (PDF)” may be clearer. If it is a confirmed downloadable file, identify the type and useful size information when available. Avoid promising an exact filename if the delivery arrangement does not reliably provide it.

Do not try to solve an uncooperative third-party link by building an unrestricted server proxy. Work with resources you control or use the provider’s supported delivery method, with appropriate access controls.

For a small acceptance test, cover the normal file, an unavailable file and an expired authenticated session. The user should receive an understandable result in each case, not a success-looking button that silently retrieves a login page.

The attribute expresses download intent within the browser’s rules. A dependable experience comes from checking the whole delivery path and using interface text that accurately describes the result.