Search code examples
htmlanchorepub

What is the expectation when <a> tag's href is a html file and download attribute is added?


<a href='1.html' download> Download 1.html </a>

For example the above HTML code, What should be the expectation when users clicks on the hyperlink??

  1. Should redirect the users to 1.html
  2. Should allow the users to download 1.html
  3. Others?

As I am developing on a epub reader, would like to know the expectation of the above behavior of above case if the HTML (e.g. 1.html) is not included in the spine item.


Solution

  • According to W3Schools, the download attribute does indeed do what you want: the file should be automatically downloaded instead of being viewed in the browser.

    This is, of course, unrelated to whether the file 1.html is included in the EPUB's spine - the spine indicates the reading order of the files from the manifest, and 1.html could be in the EPUB or external, and even if in the manifest, it may or may not be in the spine! I guess you're trying to provide a download option in your EPUB reader for particular files from inside the EPUB package?