News for hackers. Stuff that matters.
Re:Next.js 13 by chrisco255 on Tuesday October 25, 2022 @04:17PM (#33335580)
Instead use the ARIA tag role="presentation": https://developer.mozilla.org/en-US/docs/Web/Accessibility/A... to indicate when an element has no semantic meaning and is purely visual.
Re:Next.js 13 by krono on Tuesday October 25, 2022 @06:26PM (#33336967)
Which of these tags you should use and what they should contain is entirely context dependant.

That said, the use of empty alt tags is generally discouraged and not allowed together with the ARIA presentation role in most cases.

This weird requirement will steer developers towards non-compliant implementations. It's really stupid.

https://html.spec.whatwg.org/multipage/images.html#alt

https://w3c.github.io/aria/#presentation

https://w3c.github.io/aria-practices/#presentation_role

Re:Next.js 13 by chrisco255 on Tuesday October 25, 2022 @10:16PM (#33338936)
That second link from W3C gives this very example:

https://w3c.github.io/aria/#example-13

"In the following code sample, the containing img and is appropriately labeled by the caption paragraph. In this example the img element can be marked as presentation because the role and the text alternatives are provided by the containing element."

<img src="example.png" role="presentation" alt="">

So empty alt tags are not discouraged.

Re:Next.js 13 by krono on Wednesday October 26, 2022 @06:47AM (#33341927)
Hence the generally discouraged - as in not recommended in the majority of situations but exceptions exist (such as the one you provided).
Re:Next.js 13 by Vinnl on Wednesday October 26, 2022 @02:52AM (#33340594)
As I read that page, role="presentation" is intended to remove the natural semantics of a tag (e.g. have an <h2> be treated as a <div>), rather than to tell the user that there is nothing relevant to them in the given tag?
Re:Next.js 13 by klipilicica on Wednesday October 26, 2022 @09:53AM (#33343719)
"presentation" is the default role for an <img> element when the "alt" attribute is an empty string.