How To Create A Download Link - W3Schools

How TO - Download Link ❮ Previous Next ❯

Learn how to create a download link with HTML.

Download Link

You can use the HTML download attribute to specify that the target will be downloaded when a user clicks on the hyperlink.

Example

<a href="/images/myw3schoolsimage.jpg" download> <img src="/images/myw3schoolsimage.jpg" alt="W3Schools"></a> Try it Yourself »

The download attribute is only used if the href attribute is set.

The value of the attribute will be the name of the downloaded file. There are no restrictions on allowed values, and the browser will automatically detect the correct file extension and add it to the file (.img, .pdf, .txt, .html, etc.).

You can also specify a value for the download attribute, which will be the new filename of the downloaded file. If the value is omitted, the original filename is used.

Example

Specify a value for the download attribute, which will be the new filename of the downloaded file ("w3logo.jpg" instead of "myw3schoolsimage.jpg"):

<a href="/images/myw3schoolsimage.jpg" download="w3logo"> <img src="/images/myw3schoolsimage.jpg" alt="W3Schools"></a> Try it Yourself »

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Attribute
download 14.0 13.0 20.0 10.1 15.0
❮ Previous Next ❯ +1 Track your progress - it's free! Log in Sign Up

Từ khóa » Html Page Download