w3c / w3c/csswg-drafts

[css-conditional] [css-contain] `srcset` and `sizes` interaction with container queries

Open
#5,889 41 comments 76 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-conditional-6
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

With container queries, the way developers write responsive styles changes from querying the global page for information to querying for a parent with containment for information. This shifts responsive paradigms. One case I can forsee is the need to query the parent for sizing and placement of its children. This includes srcset and sizes for responsive images

See also, the need for cw and ch units: #5888

Would the following be able to work with container queries instead of global queries? (ignore syntax, just trying to show the idea):

<img srcset="elva-fairy-480w.jpg 480w,
             elva-fairy-800w.jpg 800w"
     sizes="container(max-width: 600px) 480px,
            800px"
     src="elva-fairy-800w.jpg"
     alt="Elva dressed as a fairy">
<picture>
  <source container="(max-width: 799px)" srcset="elva-480w-close-portrait.jpg">
  <source container="(min-width: 800px)" srcset="elva-800w.jpg">
  <img src="elva-800w.jpg" alt="Chris standing up holding his daughter Elva">
</picture>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the responsive-images reference linked in the issue and compare its srcset, sizes, and picture examples with the proposed container-query behavior. Review related issue #5888; the work is done when the interaction and required syntax have an agreed specification direction.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, html
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.