Content · Web Development · HTML

HTML download Attribute: Downloadable Links

The download attribute suggests downloading a resource rather than navigating to it. An optional value suggests a filename.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

The download attribute suggests downloading a resource rather than navigating to it. An optional value suggests a filename. The important question is always where the link leads and whether the person reading the page can predict it.

What You Need to Know


Browser behavior depends on origin and response headers. A same-origin download is the most predictable demonstration; the attribute is not a file security mechanism.

Example: See It in Action


Here is a simple example to experiment with. Type it, save the file, and check what the browser displays.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

<p>Download the worksheet for today's lesson:</p>
<a href="files/worksheet.pdf" download="lesson-worksheet.pdf">
    Download the PDF worksheet
</a>

Let’s Understand the Example


  • An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
  • A p groups a paragraph of related text. Start another paragraph for a new thought.
  • Download suggests saving the linked resource rather than navigating to it; browser and origin rules can affect the result.
  • Href contains the destination of a link. A value starting with # points to an id on the same page.

The first example link points to files/worksheet.pdf. Check whether that destination exists relative to the document. A link changes where readers go; it does not perform an action such as saving a form.

What Should You See?


You should see a link named “Download the PDF worksheet”. Selecting it leads to files/worksheet.pdf when that destination exists. Try it with the mouse and the keyboard.

Imagine this link is read out of context. Would its text still explain the destination? Rename unclear links before trying to make them look nicer with CSS.

Try It Yourself


  1. Add a second download link for a local text file.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Assuming download guarantees a cross-origin file will be saved with the suggested name.
  • Avoid dead links, empty href values and clickable-looking text without a real destination.

Key Takeaways


  • The download attribute suggests downloading a resource rather than navigating to it.
  • An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
  • Browser behavior depends on origin and response headers. A same-origin download is the most predictable demonstration; the attribute is not a file security mechanism.
Share this resourceSend this page to someone who may find it useful.