Skip to content

Add alt attributes to source elements #6627

Open
@johannesodland

Description

When picture elements are used for art direction (using source elements with media queries) they use distinct images depending on the environment/screen. These images might have a different layout to adapt to the screen, and would benefit from distinct replacement texts that match the selected image source.

Example

A picture element has been used for art direction. For vertical screens there is an image with a circle on the top and a box on the bottom. For horizontal screens there is an image with a circle on the left and a box on the right.

<picture>
  <source src="horizontal.jpg" media="(min-aspect: 1/1)">
  <img src="vertical.jpg" alt="A circle and a box">
</picture>

Proposal

source elements could support an alt attribute that is set on the img element when the source is selected. (Similar to how width and height properties now are set on img when a source is selceted: #5894)

<picture>
  <source src="horizontal.jpg" media="(min-aspect: 1/1)" alt="A circle to the left of a box">
  <img src="vertical.jpg" alt="A circle above a box">
</picture>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    accessibilityAffects accessibilityaddition/proposalNew features or enhancementsi18n-trackerGroup bringing to attention of Internationalization, or tracked by i18n but not needing response.needs implementer interestMoving the issue forward requires implementers to express interesttopic: img

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions