Breakdance4fun Logo

How to add the download attribute to a link or button

The download attribute in HTML is used with anchor (<a>) elements to indicate that the target of the link should be downloaded rather than navigated to. When a user clicks on a link with the download attribute, the browser will download the linked file instead of opening it in the browser window.

See how it works - compare these two buttons:

without download attribute
with download attribute

Adding the download attribute to a Text Link element:

To enable file downloads with a Text Link, simply add the download attribute and specify a value for it. If you don't add a value, the attribute won't be added.

Text link download attribute

Adding the download attribute to a Button element

When working with button elements, there's an important distinction to note. Since the <a> tag is wrapped in a Div, simply adding the download attribute like you would with a Text Link element won't work as expected - the attribute would be applied to the Div instead of the actual link.

Fortunately, there is a simple solution to ensure the download attribute gets properly applied to the link itself. Note that this time you don't need to add a value.

Button download attribute

Adding the download attribute in a Rich Text element

To enable file downloads in a Rich Text element, you'll need to manually add the download attribute. Here's how:

  1. Insert your text and create the link normally
  2. Switch the editor to Text mode
  3. Add download inside your anchor tag

Example: Download my cool PDF

Rich text download attribute