Skip to content

whitespace-only alt attribute treated differently #605

Description

@giacomo-petri

In the Clarify that a whitespace-only alt attribute should be considered as the empty string PR, we clarified that alt=" " should be treated the same as alt="".

The WPT test linked in in that PR confirms that the accessible name is handled consistently, but we currently do not have a test covering the computed role. In practice, implementations are inconsistent when handling images with whitespace-only alt values.

Below are the results from a WPT test I created locally:

  • Safari: Action get_computed_role completed with result none (consistent)
  • Chrome: Action get_computed_role completed with result image (inconsistent)
  • Firefox: Action get_computed_role completed with result image (inconsistent)

I believe this update should also have prompted implementors to verify role computation behavior.

@cookiecrook, if there are no objections, I can take care of creating a WPT issue in Accessibility Interop and submitting a PR to add my local test to html-aam/roles.html (or should I create a tentative because of inconsistencies)?

Note: @scottaohara, do you think we should also clarify in ARIA in HTML that:

If the img has an empty alt (alt="") and lacks any other img naming methods:
role=none, role=presentation

also applies when the alt value contains only whitespace characters?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions