Last Updated: February 25, 2016
·
983
· jacopoch

HTML5 Download Attribute

There are a couple of neat features in HTML5 that you should consider using more and more.

One of these is the download attribute, this allows you to set a separate file download name than the actual link endpoint, it is very useful if the file is e.g. dynamically generated and has some un-friendly names.

<!-- Download as "vacationPictures.zip" -->
<a href="/files/adlafjlxjewfasd89asd8f.zip" download="vacationPictures.zip">Download your pictures here</a>

You don't want your user to download something like t3784tg7834t7.zip, don't you?

Ah, the download attribute also forces the browser to download the linked file, this is particularly useful when dealing with pdf files as the common mistake is to serve links to those kind of files, requiring the browser to hang on while downloading the whole file in the background.