I don't want to change this, but I want to propose that we...">

Propose conformance addition for decorative img elements · Issue #452 · w3c/html-aria (original) (raw)

Right now, this is the way that an author crafts a conformant image element that is purely presentational:

<img src="photo.webp" alt="" />

I don't want to change this, but I want to propose that we add an additional invocation that does not fail conformance checkers:

<img src="photo.webp" alt="" role="none" />
<img src="photo.webp" alt="" role="presentational" />

Why

With the advancements in IDEs, many elements have TAB completion. So I can type img in my file, and press TAB, and end up with <img src="" alt="" />

This is very convenient! But what it does is take away what was previously the sole indicator of author intent- the presence of an alt attribute and whether there was a value or not. With the alt attribute being added automatically, it is still very easy for an author to ignore putting a value in the code for the attribute.

The way I have done this in some code checkers is to check for the combination of an empty alt attribute and the role="none" (or presentation). If only the alt attribute is there, I throw an error, which is used to get the developers attention.

However, this approach fails current validation checkers.

Proposal

As such, I propose that we should allow three ways to indicate that an image is purely decorative:

<img src="photo.webp" alt="" />
<img src="photo.webp" alt="" role="none" />
<img src="photo.webp" alt="" role="presentational" />

This would support the lovely advancements in convenience that IDEs have made while also still providing a good way for validators to ensure intent.