Custom <a> attribute 'download'

Hi!

I have a link block which gets its URL from a CMS record. The URL points to a PDF. The link works and opens the PDF in the browser. So far, so good. But:

I would like to force the download of the PDF using the HTML5 download attribute in the link, like
<a href="file.pdf" download>Click here</a>
So I’ve tried using the custom link attribute in the link block settings in the designer. Unfortunately an attribute named “download” is not accepted saying “this is a reserved name”.

Any ideas how to add a download attribute to an a-element in Webflow?

BR,
Norbert

We should be able to do it with custom attributes.

The correct syntax for download is:

<a href="path/file.jpg" download="Picture of an elephant">Download the picture of an elephant</a>

So it’s exactly a custom attribute. But the Download name is reserved by Webflow.

http://vincent.polenordstudio.fr/snap/u9koc.jpg

So, you can use a custom code element to address that. It works with CMS. As soon as you have a custom code element inside a dynamic list, you can inject some of you CMS data into the code. Here you’d possibly need to retrieve the URL of the file and the description of the download.

Select the URL, then the description, and click +Add field on the top right corner to link that portion of code to your database.

http://vincent.polenordstudio.fr/snap/n5dgu.jpg

2 Likes

Where is your pdf hosted at?

See this if you are using the popular file hosting sites: https://milanaryal.com/direct-linking-to-your-files-on-dropbox-google-drive-and-onedrive/

Hi Vincent,
thanks for the hint. I see custom code is a workaround.
However, it’s a pity that Webflow blocks HTML standard attributes.

The PDFs are hosted at one of our subdomains - standard webhosting.

There’s maybe a good reason but I don’t know about it :slight_smile: Click attribute and a lot of cool others are blocked too.

@cyberdave is there any disclosable info about the reserved terms?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.