Re: [csswg-drafts] [css2] Clarify 10.6.2: height with auto sizing, intrinsic ratio, and intrinsic height (#12254)

> So it doesn't mean that the used width is a special undefined value, it still needs to be a length, it's just not defined how this length is produced.

Ah, I see what you mean now.

>It's undefined, so browsers can do whatever they want (according to CSS2, not to CSS Sizing).

> Note `aspect-ratio` isn't in CSS2. But anyways your `img` isn't replaced and has `display: inline`, better try with `display: block`. Or `<svg viewbox="0 0 1 1" style="background-color: blue">`.

I had a typo earlier with the stray `<span>`. What I meant was:

```html
<!DOCTYPE html>
<div>
  <img src="" alt="test" style="background-color: blue; aspect-ratio: 1 / 1" />
</div>
```

In Chrome, the dev tools computed styles are:

contain-intrinsic-width: none
contain-intrinsic-height: none
width: 38.225px
height: 18.4px
aspect-ratio: auto

So it looks like the dimensions are being influenced by the text placeholder (e.g the broken image icon), and the `aspect-ratio` is ignored entirely.

As [CSS Sizing 4](https://www.w3.org/TR/css-sizing-4/#aspect-ratio) points out:

> ISSUE6: CSS2.1 does not cleanly differentiate between replaced elements vs. elements with an aspect ratio; need to figure out specific cases that are unclear and define them, either in the appropriate Level 3 spec or here.

So the question is: Should a replaced element with an aspect-ratio and no intrinsic size be treated how? Right now, it seems like the behavior is not covered by either CSS2.1 or modern specs.





-- 
GitHub Notification of comment by gitspeaks
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12254#issuecomment-2931323915 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 2 June 2025 15:44:51 UTC