aria icon indicating copy to clipboard operation
aria copied to clipboard

alt vs title: HTML-AAM and accname specs have conflicting requirements

Open sideshowbarker opened this issue 7 months ago • 8 comments

Given an img with an empty alt attribute and a non-empty title attribute, the HTML-AAM spec requires using the empty alt value as the accessible name. But the accname spec requires ignoring that empty alt and instead using the non-empty title value.

Details

At https://w3c.github.io/html-aam/#img-element-accessible-name-computation the HTML-AAM spec says this:

  1. If the img element has an aria-label or an aria-labelledby attribute the accessible name is to be calculated using the algorithm defined in Accessible Name and Description: Computation and API Mappings.
  2. Otherwise use alt attribute, even if its value is the empty string. Note: An img with an alt attribute whose value is the empty string is mapped to the presentation role. It has no accessible name.
  3. Otherwise, if there is no alt attribute use the title attribute.
  4. Otherwise there is no accessible name.

Note in particular, the even if its value is the empty string language.

But at https://w3c.github.io/accname/#comp_host_language_label, the accname spec says this:

E. Host Language Label: Otherwise, if the current node's native markup provides an attribute (e.g. alt) or element (e.g. HTML label or SVG title) that defines a text alternative, return that alternative in the form of a flat string as defined by the host language, unless the element is marked as presentational (role="presentation" or role="none").

Because an alt attribute with the value of the empty string (alt="") marks the element as presentational, then a reasonable reading of that accname requirement cited above is:

When the alt value is the empty string, the algorithm reaches the unless the element is marked as presentational part — in which case the requirement is to not return the alternative, but instead fall through (skip) the E. Host Language Label step, and so then move on to using the title value.

In other words, the accname spec says to ignore the empty alt, but the HTML-AAM instead requires using it.

Link to the version of the specification or documentation you were looking at at.

  • https://w3c.github.io/html-aam/#img-element-accessible-name-computation
  • https://w3c.github.io/accname/#comp_host_language_label

Does the issue exists in the editors draft (the editors draft is the most recent draft of the specification)?

Yes

sideshowbarker avatar Mar 25 '25 12:03 sideshowbarker