snippethtmlTip
Customize the names of downloadable files
Viewed 0 times
namesfilescustomizehtmlthedownloadable
Problem
HTML5 introduced a variety of convenient features that many of us use every day. As downloadable links aren't something I work with very often, I recently found out that you can use the
download attribute on an <a> element for much more than just making it trigger a download. In fact, you can pass it a string value that will act as the name of the downloadable file, effectively allowing you to customize its name:Solution
<!-- The downloaded file will be named 'June-2020.csv' -->
<a href="/data/2020/06/report.csv" download="June-2020.csv">June 2020</a>Code Snippets
<!-- The downloaded file will be named 'June-2020.csv' -->
<a href="/data/2020/06/report.csv" download="June-2020.csv">June 2020</a>Context
From 30-seconds-of-code: custom-file-download-names
Revisions (0)
No revisions yet.