What fresh hell is THIS now? - Patrick Lauke
button
element, or “going somewhere” (to a file) and thus an a
element?
[svinkle] @jhetrick It’s a good question. I feel like it could go either way.
With an a
, the href
value would serve as the path to the file for download. Problem is the focus remains on the a
which sort of defeats conveying its semantic meaning.
Using a button
kind of makes sense, as you’re invoking an action that typically results with a dialog at the operating system level. That said, you’d need JS to go fetch the file on the client event, so that’s not ideal either.
I’m learning towards a
. For example, downloading a .zip
archive from GitHub:
<a href="/[user]/[project]/archive/master.zip" class="btn btn-outline get-repo-btn " rel="nofollow" data-ga-click="Repository, download zip, location:repo overview"> Download ZIP </a>
a
as well, with “Download” somewhere in the link text
[scottohara] Sounds like you've gotten this worked out, but my two cents here since I don't notice them mentioned above:
The existence of the download
attribute, for use on <a>
elements, helped from allowing me to pontificate too hard on whether a
vs button
was the right element.
also, you wouldn't want the downloading of a file to be tied to the need for JS. Browsers will navigate to and render file types that they can understand (when not using the download attribute, or if the attribute is not understood. So it is still properly serving as a link). And the browser will load download dialogs for those file types they can't render.
download
attribute also lets you specify human-friendly names for the download, while maintaining machine-friendly names on the CDN
aria-activedescendant
? Or any opinions on using it vs. moving actual focus? (In this case specifically for something like a combobox/listbox)
<a href="path/to/file.pdf"> Download [unique identifier] <img src="images/pdf.png" alt=", opens PDF file"> </a>
aria-activedescendant
when implementing an autocomplete widget. Even then, I wasn’t sure if it really help with any sort of context, but good to follow spec.
aria-owns
, like in a combobox (although maybe I’m doing something else wrong, and aria-owns
is just incidental)