HTML: Help users to download files with the HTML download attributeLast updated: 29th March 2023
If you add a
download attribute on an anchor tag, the browser will download the resource!
<a download href="octopus.jpg">Download octopus pic</a>
The browser can use the image URL as a default file name for the downloaded file, or you can specify an attribute value e.g.
octopus.jpg which configures the file name of the downloaded file.
If you use an attribute value with slashes, like this:
The browser downloads the file as
some_long_path_picture.jpg - a little tip worth knowing about.
This works with other file types too, like
.json. Try it out - it works in all modern browsers.