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-flexbox] When omitted from the flex shorthand the flex-basis value is... #5742
This change would have a pretty big risk of causing compat issues, since it'd change the flex basis from definite to potentially-indefinite (depending on whether the flex container's main size is definite or indefinite); and that changes the decision-tree for the calculation of the flex base size inhttps://drafts.csswg.org/css-flexbox-1/#algo-main-item
[EDIT: as @Loirooriol noted, I had things backwards here - the current implemented behavior is 0%, whereas the spec was changed to require 0. The webcompat risk remains, though.]
@dholbert Isn't it the other way round? If the spec changes from 0 to 0%, since browsers are already using 0%, there won't be compat issues. If browsers change from 0% to 0 to match the spec, then the flex basis will change from potentially-indefinite to definite.
Changing 0% to 0 in browsers requires implementing the intrinsic size algorithm from the spec, especially for the block axis. Otherwise, column flexboxes with auto height would size to zero in the simple case.
Sorry, you're right - I had the situation backwards. But yes, browsers currently disagree with the spec, and if we changed browser-behavior (to match the spec) then it seems like it'd risk compat issues, due to taking a different path through the decision tree at https://drafts.csswg.org/css-flexbox-1/#algo-main-item. That's the gist of what I meant to say above.
<style>
.c {
display: inline-flex;
flex-direction: column;
width:100px;
min-height:100px;
/* important: height is unspecified, which gives special significance to 0% height values on our children (e.g. implicit flex-basis:0%) */border:1px solid black;
}
.c>* {
min-height:5px;
background: orange;
}
.flex0 { flex:0; }
.flex0_0 { flex:00; /* note: 2nd unitless-0 just parses as flex-shrink */ }
.flex0_0pct { flex:00%; }
.flex0_0px { flex:00px; }
.flex0_0_0 { flex:000; }
</style><divclass="c"><divclass="flex0">flex:0</div></div><divclass="c"><divclass="flex0_0">flex:0 0</div></div><divclass="c"><divclass="flex0_0pct">flex:0 0%</div></div><divclass="c"><divclass="flex0_0px">flex:0 0px</div></div><divclass="c"><divclass="flex0_0_0">flex:0 0 0</div></div>
Here's a screenshot showing how that testcase renders in current WebKit / Blink / Gecko:
In the first two boxes in the testcase, the orange background (the flex item) renders as tall as its text, by virtue of the fact that browsers are interpreting the flex expression as implying flex-basis:0%, and browsers are then resolving the 0% to content due to the indefinite size of the flex container.
If we implement the spec change and use unitless 0 (i.e. 0px) instead, then browsers would render the first two boxes the same way that they render the last two boxes, with a collapsed flex item height. This may cause webcompat issues, particularly in cases where the flex item has overflow:hidden|scroll|auto and collapses away without overflow being visible.
This is the same as my previous testcase, but with overflow:auto instead of min-height:5px (possibly more representative of real-world content; note that any non-default value of overflow would make the same point here).
In this testcase, items with implicit flex-basis:0% still render just fine, but items with flex-basis:0 or 0px don't render at all:
If browsers were to implement the spec change, then the first two black-bordered boxes here would become blank (like the last two). I'm a bit worried that real-world web content would end up with pieces unexpectedly disappearing for that reason.
I would like to cast a vote for "yes". I've tripped over this a lot because 0% height can get translated to "auto". The fact that 0 and 0% are different is highly confusing. A unitless default would be better for the principle of least surprise.
The CSS Working Group just discussed [css-flexbox] When omitted from the flex shorthand the flex-basis value is..., and agreed to the following:
RESOLVED: Switch omitted flex-basis back to 0% for compat, add a note to the spec about it
The full IRC log of that discussion
<fantasai> TabAtkins: Along while ago, we defined that the value of flex-basis when you don't specify the basis would be 0%
<fantasai> TabAtkins: This was specifically to trigger indeterminate behavior
<fantasai> TabAtkins: Later tried to change it, to say that you get 0px
<fantasai> TabAtkins: We were unclear at the time whether it would be Web-compatible to do
<fantasai> TabAtkins: Implementations have not really followed the spec change here. They've kept 0%
<fantasai> TabAtkins: At this point, we're fairly certain it can't be changed
<fantasai> TabAtkins: So that it doesn't go down to zero
<fantasai> TabAtkins: We see cases where they are depending on that.
<fantasai> TabAtkins: So proposal is to revert
<fantasai> TabAtkins: Probably need to call out in the spec that it's a little weird but required for back-compat
<TabAtkins> fantasai: I think at this point this is probably correct
<TabAtkins> fantasai: the original idea is we would rely on automatic minimum to prevent these problems we were trying to solve with 0%, that gives a little more flexilibity
<TabAtkins> fantasai: but that does give slightly different behavior, basis of max-content vs flooring it at min-content is quite different, or at least can be different
<fantasai> PROPOSED: Switch back to 0% for compat, add a note to the spec about it
<fantasai> RESOLVED: Switch omitted flex-basis back to 0% for compat, add a note to the spec about it
Activity
emilio commentedon Nov 24, 2020
cc @lilles @dholbert
dholbert commentedon Nov 25, 2020
For what it's worth, the still-open mozilla bug
on switching fromis https://bugzilla.mozilla.org/show_bug.cgi?id=1368592.0to0%This change would have a pretty big risk of causing compat issues, since
it'd change the flex basis from definite to potentially-indefinite (depending on whether the flex container's main size is definite or indefinite); and that changes the decision-tree for the calculation of the flex base size inhttps://drafts.csswg.org/css-flexbox-1/#algo-main-item[EDIT: as @Loirooriol noted, I had things backwards here - the current implemented behavior is 0%, whereas the spec was changed to require 0. The webcompat risk remains, though.]
Loirooriol commentedon Nov 25, 2020
@dholbert Isn't it the other way round? If the spec changes from
0to0%, since browsers are already using0%, there won't be compat issues. If browsers change from0%to0to match the spec, then the flex basis will change from potentially-indefinite to definite.lilles commentedon Nov 25, 2020
Adding @davidsgrogan @cbiesinger for Blink.
cbiesinger commentedon Nov 25, 2020
Changing 0% to 0 in browsers requires implementing the intrinsic size algorithm from the spec, especially for the block axis. Otherwise, column flexboxes with auto height would size to zero in the simple case.
dholbert commentedon Nov 26, 2020
Sorry, you're right - I had the situation backwards. But yes, browsers currently disagree with the spec, and if we changed browser-behavior (to match the spec) then it seems like it'd risk compat issues, due to taking a different path through the decision tree at https://drafts.csswg.org/css-flexbox-1/#algo-main-item. That's the gist of what I meant to say above.
dholbert commentedon Apr 18, 2023
Here's a concrete example of where a browser implementing the spec might present a webcompat issue:
https://bug1368592.bmoattachments.org/attachment.cgi?id=9329106
Here's a screenshot showing how that testcase renders in current WebKit / Blink / Gecko:

In the first two boxes in the testcase, the orange background (the flex item) renders as tall as its text, by virtue of the fact that browsers are interpreting the
flexexpression as implyingflex-basis:0%, and browsers are then resolving the 0% tocontentdue to the indefinite size of the flex container.If we implement the spec change and use unitless
0(i.e.0px) instead, then browsers would render the first two boxes the same way that they render the last two boxes, with a collapsed flex item height. This may cause webcompat issues, particularly in cases where the flex item hasoverflow:hidden|scroll|autoand collapses away without overflow being visible.dholbert commentedon Apr 18, 2023
More concerning scenario, from a webcompat perspective:
https://bug1368592.bmoattachments.org/attachment.cgi?id=9329111
This is the same as my previous testcase, but with
overflow:autoinstead ofmin-height:5px(possibly more representative of real-world content; note that any non-default value ofoverflowwould make the same point here).In this testcase, items with implicit

flex-basis:0%still render just fine, but items withflex-basis:0or0pxdon't render at all:If browsers were to implement the spec change, then the first two black-bordered boxes here would become blank (like the last two). I'm a bit worried that real-world web content would end up with pieces unexpectedly disappearing for that reason.
Loirooriol commentedon Apr 18, 2023
Maybe a counter could be added, or a HTTPArchive search or something, to see how many websites would be impacted?
LibWeb: Fix broken handling of `flex: <flex-grow>` shorthand
LibWeb: Fix broken handling of `flex: <flex-grow>` shorthand
camsteffen commentedon Aug 19, 2024
I would like to cast a vote for "yes". I've tripped over this a lot because
0%height can get translated to "auto". The fact that0and0%are different is highly confusing. A unitless default would be better for the principle of least surprise.Example sandbox
bfgeek commentedon Aug 27, 2024
Fwiw - this likely isn't web compatible anymore. Spec should be changed back to reflect reality.
bfgeek commentedon Jul 27, 2026
Note to future self - this definitely wont be web compatible anymore.
bfgeek commentedon Jul 29, 2026
I might not make the call tomorrow - but specifically the case below is relatively common + lots of variations on this:
tabatkins commentedon Jul 29, 2026
(I'm happy to take this topic is Ian's not in.)
css-meeting-bot commentedon Jul 29, 2026
The CSS Working Group just discussed
[css-flexbox] When omitted from the flex shorthand the flex-basis value is..., and agreed to the following:RESOLVED: Switch omitted flex-basis back to 0% for compat, add a note to the spec about itThe full IRC log of that discussion
<fantasai> TabAtkins: Along while ago, we defined that the value of flex-basis when you don't specify the basis would be 0%<fantasai> TabAtkins: This was specifically to trigger indeterminate behavior
<fantasai> TabAtkins: Later tried to change it, to say that you get 0px
<fantasai> TabAtkins: We were unclear at the time whether it would be Web-compatible to do
<fantasai> TabAtkins: Implementations have not really followed the spec change here. They've kept 0%
<fantasai> TabAtkins: At this point, we're fairly certain it can't be changed
<fantasai> TabAtkins: So that it doesn't go down to zero
<fantasai> TabAtkins: We see cases where they are depending on that.
<fantasai> TabAtkins: So proposal is to revert
<fantasai> TabAtkins: Probably need to call out in the spec that it's a little weird but required for back-compat
<TabAtkins> fantasai: I think at this point this is probably correct
<TabAtkins> fantasai: the original idea is we would rely on automatic minimum to prevent these problems we were trying to solve with 0%, that gives a little more flexilibity
<TabAtkins> fantasai: but that does give slightly different behavior, basis of max-content vs flooring it at min-content is quite different, or at least can be different
<fantasai> PROPOSED: Switch back to 0% for compat, add a note to the spec about it
<fantasai> RESOLVED: Switch omitted flex-basis back to 0% for compat, add a note to the spec about it