You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-position-3] Absolute positioning - Is the new inset & auto-size behaviour web-compatible? #11195
align-self: stretch should be a no-op (At least for absolute elements not within flex/grid context) in the old behaviour, but seems to be used by websites in the wild anyway in the linked bugs:
Everything is auto, margins zeroed out, top takes its static position value, which is zero
Height is Auto heights for block formatting context roots - Distance between top of the topmost line box and bottom of the bottommost line box, so auto size is basically a shrink-fit size.
Better add some background to the testcase to be able to see the size.
2 broken sites found in 6 days is not looking very good... Why are they using stretch if they don't want to stretch 🤦
So FWIW chrome didn't change static-pos'd abspos for this reason. We had a look at it, and determined that it wasn't web-compatible (sorry we should have filed an issue at that time).
The CSS Working Group just discussed [css-position-3] Absolute positioning - Is the new inset & auto-size behaviour web-compatible?, and agreed to the following:
RESOLVED: change stretch alignment case to allow the size to stretch when the normal alignment case allows stretching
The full IRC log of that discussion
<emilio> oriol: this was discussed a few weeks ago and I couldn't attend
<emilio> ... not sure if the consequences of the resolution were fully understood
<miriam> present
<emilio> ... the implication is that you can have an abspos with auto margins that if it has normal alignment it'd stretch, but if you change self-alignment to be stretch, then it will stop stretching
<emilio> ... I think that doesn't really make sense and would just cause confusion
<emilio> ... in flex and grid auto margins don't stretch even if they have stretch alignment
<emilio> ... but this happens both for stretch and normal alignment
<emilio> ... so I think it's better to have abspos be consistent
<emilio> ... and avoid having the align-self: stretch align with flex / grid
<emilio> ... also the argument for making consistent with flex/grid feels weak
<emilio> ... in block layout auto margins don't prevent block level items
<emilio> ... from stretching
<emilio> ... so I'd like to change the previous resolution
<emilio> ... so that if they stretch with normal alignment they also stretch with stretch alignment
<emilio> fantasai: whichever way we go we are going to introduce inconsistencies
<emilio> ... in terms of alignment I think being consistent with flex/grid is more important because that's what authors are used to
<emilio> ... in block layout only blink has implemented and it's very recent so we can probably change it
<emilio> ... for normal we're stuck with css2, but for the other keywords it'd introduce inconsistencies
<emilio> ... are you proposing that auto margins are stronger than centering in flex/grid but not abspos? That seems like a bad idea
<emilio> ... I think maybe changing stretch only is better than the current situation, I admit it's quite weird that stretch is less stretchy than normal
<fantasai> s/I think//
<emilio> oriol: not sure the right way to look at this is props winning over other
<emilio> ... the way i see it is both margin and alignment have some effect simultaneously
<emilio> ... e.g. both may affect the auto size to be fit-content
<emilio> ... also auto-margins work by changing the margin box and alignment works in terms of that box
<emilio> ... so if you have auto margins that fills the whole container alignment won't do anything, but it's not like it is disabled
<emilio> ... it's more like it doesn't matter which value you use
<emilio> ... whether we decide that self-alignment forces auto size to be fit-content or auto margins do that I think it's independent decisions
<emilio> ... and it's not like some values win and they don't
<emilio> s/they/don't
<emilio> s/they/some
<emilio> ... e.g. even tho in flex and grid auto margins prevent stretching
<emilio> ... then center alignment could prevent stretching even with a 0 margin
<emilio> ... so we could say that center alignment is "winning" over the 0 margin
<emilio> ... so what wins and loses can be subjective
<emilio> ... I prefer seeing it as different things applying simultaneously
<emilio> fantasai: so iiuc, if you have auto margins and stretch, the first thing you do is stretch
<emilio> ... then auto margins end up having no effect (unless max-size is involved)
<emilio> oriol: exactly
<emilio> ... so in this case for abspos neither auto margins nor stretch alignment force fit-content size (so it can stretch)
<emilio> ... typically alignments won't matter because auto margins will resolve to 0 and then alignment would do nothing
<emilio> ... but if you have a max-size then you can align stuff using the alignment properties
<emilio> fantasai: I think that makes sense. There's a weird clause about negative and auto in this case, need to go back and check, but should be fine
<emilio> astearns: so prev resolution is no change to the spec, what should the spec say
<emilio> oriol: a way to word could be "change stretch alignment case to allow the size to stretch when the normal alignment case allows stretching"
<emilio> astearns: makes sense, wdyt fantasai?
<emilio> fantasai: yeah
<emilio> +1
<emilio> RESOLVED: change stretch alignment case to allow the size to stretch when the normal alignment case allows stretching
Activity
emilio commentedon Nov 13, 2024
@dshin-moz you're probably missing a
position: absolutein your test-case as well, right?cc @fantasai @tabatkins
dshin-moz commentedon Nov 13, 2024
Fixed. Thanks!
Loirooriol commentedon Nov 13, 2024
Better add some background to the testcase to be able to see the size.
2 broken sites found in 6 days is not looking very good... Why are they using
stretchif they don't want to stretch 🤦Loirooriol commentedon Nov 14, 2024
Actually, the default is
align-self: auto, which behaves asnormal, which behaves asstretch.So this means that you should get this behavior even without
align-self: stretch, which is obviously wrong.dshin-moz commentedon Nov 14, 2024
You're right that
align-self: auto->normal, but then:So given that the testcase has auto insets, it ends up being content-fit size, I think
EDIT: Ah, I see you've filed #11215 regarding that.
bfgeek commentedon Apr 3, 2025
So FWIW chrome didn't change static-pos'd abspos for this reason. We had a look at it, and determined that it wasn't web-compatible (sorry we should have filed an issue at that time).
Loirooriol commentedon Apr 15, 2025
Yeah, in Servo we tried a few testcases on major browsers, and came to the conclusion that the automatic size of an abspos needs to be
fit-contentwhen one or both insets areauto, even if the self-alignment property isstretch.https://github.com/servo/servo/blob/da4ea0f0965414733f0352e76ff416b1ded75a08/components/layout_2020/positioned.rs#L821,L829
Authors can still use
height: stretchif they really want to stretch.Loirooriol commentedon Apr 15, 2025
Actually, it has already been fixed in the spec (#11902): https://drafts.csswg.org/css-position-3/#abspos-auto-size
Well, the "nor margins in that axis are auto" is wrong: browsers still allow stretching.
15 remaining items
Bug 1963501 [wpt PR 52261] - [abspos] Only stretch when we have no au…
Bug 1963501 [wpt PR 52261] - [abspos] Only stretch when we have no au…
Bug 1963501 [wpt PR 52261] - [abspos] Only stretch when we have no au…
fantasai commentedon May 14, 2025
This is not true. The box may have a non-stretch-fit size, in which case alignment is observable.
css-meeting-bot commentedon May 14, 2025
The CSS Working Group just discussed
[css-position-3] Absolute positioning - Is the new inset & auto-size behaviour web-compatible?, and agreed to the following:RESOLVED: change stretch alignment case to allow the size to stretch when the normal alignment case allows stretchingThe full IRC log of that discussion
<emilio> oriol: this was discussed a few weeks ago and I couldn't attend<emilio> ... not sure if the consequences of the resolution were fully understood
<miriam> present
<emilio> ... the implication is that you can have an abspos with auto margins that if it has normal alignment it'd stretch, but if you change self-alignment to be stretch, then it will stop stretching
<emilio> ... I think that doesn't really make sense and would just cause confusion
<emilio> ... in flex and grid auto margins don't stretch even if they have stretch alignment
<emilio> ... but this happens both for stretch and normal alignment
<emilio> ... so I think it's better to have abspos be consistent
<emilio> ... and avoid having the align-self: stretch align with flex / grid
<emilio> ... also the argument for making consistent with flex/grid feels weak
<emilio> ... in block layout auto margins don't prevent block level items
<emilio> ... from stretching
<emilio> ... so I'd like to change the previous resolution
<emilio> ... so that if they stretch with normal alignment they also stretch with stretch alignment
<emilio> fantasai: whichever way we go we are going to introduce inconsistencies
<emilio> ... in terms of alignment I think being consistent with flex/grid is more important because that's what authors are used to
<emilio> ... in block layout only blink has implemented and it's very recent so we can probably change it
<emilio> ... for normal we're stuck with css2, but for the other keywords it'd introduce inconsistencies
<emilio> ... are you proposing that auto margins are stronger than centering in flex/grid but not abspos? That seems like a bad idea
<emilio> ... I think maybe changing stretch only is better than the current situation, I admit it's quite weird that stretch is less stretchy than normal
<fantasai> s/I think//
<emilio> oriol: not sure the right way to look at this is props winning over other
<emilio> ... the way i see it is both margin and alignment have some effect simultaneously
<emilio> ... e.g. both may affect the auto size to be fit-content
<emilio> ... also auto-margins work by changing the margin box and alignment works in terms of that box
<emilio> ... so if you have auto margins that fills the whole container alignment won't do anything, but it's not like it is disabled
<emilio> ... it's more like it doesn't matter which value you use
<emilio> ... whether we decide that self-alignment forces auto size to be fit-content or auto margins do that I think it's independent decisions
<emilio> ... and it's not like some values win and they don't
<emilio> s/they/don't
<emilio> s/they/some
<emilio> ... e.g. even tho in flex and grid auto margins prevent stretching
<emilio> ... then center alignment could prevent stretching even with a 0 margin
<emilio> ... so we could say that center alignment is "winning" over the 0 margin
<emilio> ... so what wins and loses can be subjective
<emilio> ... I prefer seeing it as different things applying simultaneously
<emilio> fantasai: so iiuc, if you have auto margins and stretch, the first thing you do is stretch
<emilio> ... then auto margins end up having no effect (unless max-size is involved)
<emilio> oriol: exactly
<emilio> ... so in this case for abspos neither auto margins nor stretch alignment force fit-content size (so it can stretch)
<emilio> ... typically alignments won't matter because auto margins will resolve to 0 and then alignment would do nothing
<emilio> ... but if you have a max-size then you can align stuff using the alignment properties
<emilio> fantasai: I think that makes sense. There's a weird clause about negative and auto in this case, need to go back and check, but should be fine
<emilio> astearns: so prev resolution is no change to the spec, what should the spec say
<emilio> oriol: a way to word could be "change stretch alignment case to allow the size to stretch when the normal alignment case allows stretching"
<emilio> astearns: makes sense, wdyt fantasai?
<emilio> fantasai: yeah
<emilio> +1
<emilio> RESOLVED: change stretch alignment case to allow the size to stretch when the normal alignment case allows stretching
bfgeek commentedon May 14, 2025
@fantasai @Loirooriol - Is it correct under the above resolution, tables should have the old behaviour? E.g.
https://www.software.hixie.ch/utilities/js/live-dom-viewer/?saved=13785
Loirooriol commentedon May 14, 2025
Oh, yeah, I failed to consider tables and replaced elements when summarizing the proposed resolution, but I guess they should be covered too.
So basically https://drafts.csswg.org/css-position/#abspos-auto-size should be changed as follows:
bfgeek commentedon May 14, 2025
Sounds good. Tables stretching is this case is more consistent IMO.
[css-position-3] Auto margins do not suppress stretch alignment. #11195
tabatkins commentedon Jan 30, 2026
Thanks, updated the draft.