HTML5 Download Attribute

Michael Walsh
By Michael WalshPublished

A handy anchor tag attribute that can force the user agent to download a file it would normally attempt to display.

This little known anchor tag attribute can be used in a couple of ways, here’s one example:

<a href="very-large-image.jpg" download>Download wallpaper</a>

So when a user clicks on this link, rather than the user agent displaying the image as it downloads and then the user having to right-click and save, instead the file is just downloaded immediately.

Here’s another example:

<a href="37asd83jdhn857gssdnd.pdf" download="stock-status-report-2013.pdf">Download report</a>

In the above example the file is downloaded rather than displayed as per the first example but by passing in a value into the download attribute, that is used to override the randomly generated file name in the href attribute.

I believe a similar result can be achieved using the content-disposition header server-side but this seems like a quicker and simpler way to address the issue.

No surprises that other than Chrome and Firefox, browser support is currently lacking.

We use cookies to make this website work, to understand how it's used, and to measure our advertising. Find out more about cookies.

Cookie preferences

make an enquiry

Quick form · 3 steps · 1 min

How can we help?

I am looking for

Website

New marketing website, microsite or redesign

E-commerce

Shopify store, new or rebuilt

Web application From £10,000 + VAT

Bespoke software and internal tools

AI implementation From £10,000 + VAT

Practical AI in your existing systems

Data visualisation From £10,000 + VAT

Dashboards and data pipelines

Migrations, hosting & support

Website migrations, web hosting and ongoing support

Something else / not sure yet

Let's talk it through

Prefer to talk?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Step 1 of 3

We'll be in touch within one business day to discuss your project. In the meantime, feel free to drop us a line at hello@enovate.co.uk if anything else comes up.

book directly

Book a discovery call with Michael

Michael Walsh, Founder & Managing Director. Pick a time that suits you, add your name and email, and the calendar invitation is yours.

Loading available times…

You can still book through the full calendar, or send us a message.

Times shown in . The calendar invitation lands in your inbox the moment you confirm.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Booking is handled by Calendly; see our privacy policy.

You're booked in

(). The calendar invitation is on its way to .

RescheduleCancel