Skip to content

Add more documentation for sizes=auto #39464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 13, 2025
Merged

Conversation

tunetheweb
Copy link
Contributor

@tunetheweb tunetheweb commented May 9, 2025

Description

Add sizes=auto description to htmlimgageelement doc and add extra note to equivalent <img> doc (where it is documented already).

Motivation

New feature that is underdocumented.

Additional details

https://chromestatus.com/feature/5191555708616704
https://ericportis.com/posts/2023/auto-sizes-pretty-much-requires-width-and-height/

Related issues and pull requests

Was added to BCD in: mdn/browser-compat-data#23785

Was also partially added in #38025

Fixes #30596

@tunetheweb tunetheweb requested review from a team as code owners May 9, 2025 07:04
@tunetheweb tunetheweb requested review from estelle and wbamberg and removed request for a team May 9, 2025 07:04
@github-actions github-actions bot added Content:HTML Hypertext Markup Language docs Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels May 9, 2025
Copy link
Contributor

github-actions bot commented May 9, 2025

Preview URLs

External URLs (1)

URL: /en-US/docs/Web/HTML/Reference/Elements/img
Title: <img>: The Image Embed element

(comment last updated: 2025-05-12 23:59:34)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment on lines 31 to 33
- `auto`

- : You can use the value `auto` to replace the whole list of sizes or the first entry in the list. It is only valid when combined with `loading="lazy"`, and resolves to the [concrete size](/en-US/docs/Web/CSS/image) of the image. Since the intrinsic size of the image is not yet known, `width` and `height` attributes (or CSS equivalents) should also be specified to [prevent the browser assuming a default width of 300px](https://html.spec.whatwg.org/multipage/images.html#sizes-attributes:~:text=it%20is%20strongly%20encouraged%20to%20specify%20dimensions%20using%20the%20width%20and%20height%20attributes).
Copy link
Member

@Josh-Cena Josh-Cena May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: do not duplicate information about the precise attribute value syntax. This entire "Value" section could be replaced with something like "A string containing a comma-separated list of source size descriptors. For the exact syntax and description, see the [HTML reference](link)".

(Edit: actually we already do that. If you think it's confusing to mention some syntax but not others, IMO we should just remove everything.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit confusing as this page gives a brief summary of the syntax, and then a link. So think it is worthwhile to mention that auto is now supported. However, I cut it down to a single sentence. PTAL.

@tunetheweb tunetheweb requested a review from Josh-Cena May 12, 2025 23:57
Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thank you!

@Josh-Cena Josh-Cena merged commit bd6d5e5 into mdn:main May 13, 2025
8 checks passed
wbamberg added a commit to wbamberg/content that referenced this pull request May 21, 2025
* upstream/main: (40 commits)
  Add a guide on xs-leaks (mdn#38977)
  chore: Link to child pages in SVG, URI section (mdn#39470)
  Correct page title for `Uint8Array.prototype.setFromHex()` (mdn#39494)
  Bump markdownlint-cli2 from 0.17.2 to 0.18.0 (mdn#39488)
  Add more documentation for sizes=auto (mdn#39464)
  css(fix): update 'shape()' page (mdn#39454)
  Expand Compression Dictionary format description (mdn#39441)
  Add username/password section to URLs guide (mdn#39487)
  Fix typos (mdn#39481)
  CSS: mask-position property description (mdn#39449)
  Adding @starting-style to CSS nesting at-rules (mdn#39473)
  feat(aria): Add short titles, format titles for roles (mdn#39472)
  Fix Circle Collision detection algorithm (mdn#39484)
  Add warning against using element IDs as global properties. (mdn#39422)
  Fix typos in web audio spatialization basics (mdn#39476)
  More Error Messages (mdn#39419)
  Add links to CSS sidebar (mdn#39445)
  css: add 'stretch' value examples (mdn#39451)
  chore: link to unlinked child pages (mdn#39469)
  Fix typos (mdn#39465)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:HTML Hypertext Markup Language docs Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document img auto-sizes
3 participants