Is there a decent way to accessibly label silent video (think animated GIF but using `<video>` rather than a GIF)?

VTT captions feel wrong in this context, and labelling with `<figure>`, `aria-labelledby,` and `aria-label` all have mixed and often poor behaviour in different browsers. For example, no matter what you do, Firefox announces an unlabelled “image” as a child of the `<video>` element (and the `<video>` is announced as “group”). Chrome meanwhile announces the label and then “empty group”.

#accessibility #html

@swithinbank curious about two things:
1. are you using the `controls` attribute? then `aria-label`/`aria-labelledby` should work. see https://www.tpgi.com/short-note-on-aria-label-aria-labelledby-and-aria-describedby/ (2017)
2. how come `figure`+`figcaption` doesn't work reliably? it should be content-agnostic.
Short note on aria-label, aria-labelledby, and aria-describedby - TPGi

What happens when aria-label, aria-labelledby and aria-describedby are used to provide an accessible name?

TPGi

@mayank 1. No, actually. I'll try that — borrowed some existing markup we had that didn't use `controls`. Thanks for the link and hint.

2. I found the figure caption was announced, but the content was still super unclear, e.g. the video itself would still be announced as just "empty group" in Chrome.

Could be that I've got my expectations wrong though. In my head this is a content situation very similar to an image with an `alt` attribute and a single announcement along the lines of "<accessible label>, video/image" would make sense, but I guess if users expect videos to be announced a little differently, then I shouldn't be forcing something unusual.

(I did play around with `role="img"` just before logging off yesterday with some promising results, but I'm also always nervous about applying nonstandard roles.)

@swithinbank yeah i think the "group" is intentional, it's not a flat image. and it's only "empty" when there are no controls inside it.

i would not override the role, but maybe `aria-roledescription="video"` could work (though it does come with localization concerns)

@mayank Yeah `group` makes sense as a wrapper for the actual video controls when present.

I think this very specific case is a bit of an unusual one. I’m basically doing the equivalent of `<img src="/animated.gif" alt="Description of animation">` in a blog post, it just happens to be an MP4 file instead of a GIF. The animation is subtle over a small portion of the image (otherwise I’d want to provide controls) and VTT captioning doesn’t make sense (it’s essentially a static image), so exposing controls and that AT complexity feels like it gets in a user’s way for no benefit.

Using `role="img"` in our testing with NVDA and VoiceOver does seem to give us a decent experience across different browsers, announcing it as “Graphic, <accessible label>” or “<accessible label>, image”. With the main drawback being `aria-label` use which I’d prefer to avoid due to the localisation concerns you mentioned.

(The actual example: https://deploy-preview-1693--astro-www-2.netlify.app/blog/starlight-035/#custom-icons-in-asides)

Starlight 0.35 | Astro

Customize icons, attributes, and page slugs with the latest Starlight release.

Astro

@swithinbank @mayank I’ve used `role=img` with an `aria-label` before (it was a pattern we used on a website that had accessibility requirements which had to pass before shipping; we had a dedicated team of specialists reviewing our work too).

Also, I think some browsers actually support something like `<img src=video.mp4>`. This is pretty dated: https://calendar.perfplanet.com/2017/animated-gif-without-the-gif/

Evolution of <img>: Gif without the GIF

tl;dr GIFs are awesome but terrible for quality and performance Replacing GIFs with <video> is better but has perf. drawbacks: not preloaded, uses range requests Now you can <img src=".mp4">s in Safari Technology Preview Early results show mp4s in <img> tags display

Web Performance Calendar

@knowler @mayank TIL that `<img>` supports video sources — that is… surprising! 😄

And yeah, for my initial expectations, `role="img"` did work pretty well, but I think @mayank is right to say that that’s problematic because it doesn’t offer users control over pausing the animation: https://front-end.social/@mayank/114863820422569836

Mayank (@mayank@front-end.social)

@swithinbank@webtoo.ls semantic concerns aside, if you're autoplaying+looping the video then it *must* have controls, otherwise you violate SC 2.2.2 https://www.w3.org/WAI/WCAG22/Understanding/pause-stop-hide.html

Front-End Social
@swithinbank @mayank ya, in that scenario we had a play/pause button as well.
@knowler Ohhh, so some custom UI? Yeah that could work too, I guess. Probably overkill for my one animated image in a blog post, but for a system-wide solution, figuring out something like that could make sense.