top | item 33334309

(no title)

calvin | 3 years ago

You should still be able to use alt="" to indicate that it is "decorative" and not meaningful imagery for a visually-impaired user.

discuss

order

chrisco255|3 years ago

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.

krono|3 years ago

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 even allowed together with the ARIA presentation role in most cases.

This decision of theirs will steer developers towards non-compliant/asemantic code. 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

Vinnl|3 years ago

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?

klipilicica|3 years ago

"presentation" is the default role for an <img> element when the "alt" attribute is an empty string.

latchkey|3 years ago

That's like the difference between null and undefined.

cramforce|3 years ago

If you have no alt attribute, then screen readers read the URL!

Empty strings are the way to go for decorative images