News for hackers. Stuff that matters.
Re:Next.js 13 by latchkey on Tuesday October 25, 2022 @02:20PM (#33334276)

  // "alt" is now required for improved accessibility
I'm all for accessibility, but let us decide when to implement it.
Re:Next.js 13 by calvin on Tuesday October 25, 2022 @02:22PM (#33334309)
You should still be able to use alt="" to indicate that it is "decorative" and not meaningful imagery for a visually-impaired user.
Re:Next.js 13 by latchkey on Tuesday October 25, 2022 @02:35PM (#33334472)
That's like the difference between null and undefined.
Re:Next.js 13 by cramforce on Tuesday October 25, 2022 @02:37PM (#33334504)
If you have no alt attribute, then screen readers read the URL!

Empty strings are the way to go for decorative images

Re:Next.js 13 by latchkey on Tuesday October 25, 2022 @03:01PM (#33334775)
What if I have an app that no screen reader will ever read?
Re:Next.js 13 by joshka on Tuesday October 25, 2022 @06:59PM (#33337346)
Then write your own component that extends and removes the requirement. Until then, web tooling is better off explicitly acknowledging that accessibility is an explicit goal.
Re:Next.js 13 by abujazar on Tuesday October 25, 2022 @03:03PM (#33334797)
Alt is a required attribute of the <img> tag, so requiring it is just basic validation. C code won't compile if you omit the semicolon after statements, either.
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.
Re:Next.js 13 by kolanos on Tuesday October 25, 2022 @02:23PM (#33334324)
> I'm all for accessibility, but let us decide when to implement it.

Which usually means never.

Re:Next.js 13 by latchkey on Tuesday October 25, 2022 @02:36PM (#33334488)
Which is ok too. It is far better than encouraging people to write alt="" or alt="asdf".

See also (naming things): https://twitter.com/secretGeek/status/7269997868

Re:Next.js 13 by lghh on Tuesday October 25, 2022 @02:51PM (#33334647)
They are encouraging people to write alt text, not encouraging people to write alt="".

That's like saying "Typescript just encourages people to make everything `any` instead of defining types. It's a useless addition over JS." Sure, you _could_, but most actually use the actual tool.

Re:Next.js 13 by tills13 on Tuesday October 25, 2022 @03:22PM (#33334987)
alt="" has a specific and intentional meaning which is _always_ better for accessibility than an unset alt

It's 6 extra characters, you'll survive.

Re:Next.js 13 by googlryas on Tuesday October 25, 2022 @02:35PM (#33334476)
Which just means codebases will be littered with alt="" for no reason.
Re:Next.js 13 by abujazar on Tuesday October 25, 2022 @02:56PM (#33334699)
It's often better to specify alt="" than not at all, because screen readers may use the filename instead if there's no alt attribute.
Re:Next.js 13 by googlryas on Tuesday October 25, 2022 @05:00PM (#33336130)
That's actually a detriment then, if the "fix" for no a11y makes screen readers think they should use no alt text, instead of some possibly meaningful alternate.
Re:Next.js 13 by Vinnl on Wednesday October 26, 2022 @02:54AM (#33340601)
The fix for no a11y is to add a11y. In many cases (i.e. the "often" specified by GP), images contain no extra information, in which case you should indicate that by adding alt="". In other cases, you should add an actual description.
Re:Next.js 13 by googlryas on Wednesday October 26, 2022 @04:20AM (#33341117)
I meant the "fix" of people not caring about a11y(which is why I put it in quotes) and just trying to get their code to compile.

If people don't care about a11y, they aren't going to start devoting time to it because a tool puts a slight roadblock in their way - they're just going to try to bypass the tool.

Re:Next.js 13 by Vinnl on Thursday October 27, 2022 @02:56AM (#33354132)
Sure, but it doesn't really matter what you do for those people; their projects will be inaccessible anyway. For the rest of us, it's a useful reminder.
Re:Next.js 13 by lghh on Tuesday October 25, 2022 @02:49PM (#33334624)
I'd rather spend a literal 6-character burden (alt="") to put an empty string in my little hobby projects than live in a world where non-hobby projects can skip adding alt.

It should be very clear by just looking around on the internet that, when given the choice, accessibility will take a back seat.

Re:Next.js 13 by latchkey on Tuesday October 25, 2022 @03:00PM (#33334762)
I'm curious why you think that forcing people to write alt="" is going to improve accessibility?
Re:Next.js 13 by randomguy0 on Tuesday October 25, 2022 @03:55PM (#33335350)
Because that’s how screen readers know the image is decorative. It literally is/improves accessibility.
Re:Next.js 13 by lghh on Tuesday October 25, 2022 @05:18PM (#33336302)
Additionally, the developer is more likely to actually write alt text when it's not decorative.
Re:Next.js 13 by Vinnl on Wednesday October 26, 2022 @02:48AM (#33340562)
Although I must admit, I've also seen such rules leading to developers writing alt text for decorative images, and I'm not sure if that's much better.
Re:Next.js 13 by joshribakoff on Tuesday October 25, 2022 @03:04PM (#33334810)
The HTML spec says it is required, even if you don’t think it should be required it is. https://html.spec.whatwg.org/multipage/images.html#alt
Re:Next.js 13 by latchkey on Tuesday October 25, 2022 @03:09PM (#33334852)
NextJS could just create alt="" when rendering the HTML <img> element from their <Image> element.
Re:Next.js 13 by MaxLeiter on Tuesday October 25, 2022 @03:57PM (#33335371)
That could harm the experience for assistive tech users more than no alt tag
Re:Next.js 13 by dariusj18 on Tuesday October 25, 2022 @06:04PM (#33336746)
I think the compromise would be an optional build parameter that allows this functionality.
Re:Next.js 13 by Serenacula on Tuesday October 25, 2022 @09:33PM (#33338620)
Frameworks shouldn't be changing the content you coded on the sly, that's just asking for trouble. Imagine trying to debug that.
Re:Next.js 13 by Vinnl on Wednesday October 26, 2022 @02:49AM (#33340571)
Next.js can't determine what the value of the alt tag should be, i.e. whether it should actually be empty. If it would do this, it would actually tell screen reader users that the image is decorative, instead of warning them that there might be information conveyed in the image that the developer forgot to label.