-
Notifications
You must be signed in to change notification settings - Fork 715
[css-align] justify-items
and anonymous block boxes
#11461
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
Comments
But how would you allow aligning 'anonymous blocks' to the end if that's the desired behavior? |
There is of course a trade-off, we need to think which option will be less confusing. |
That's beside the point since we're no longer dealing with anonymous block boxes in that case. I think keeping the |
I don't think most authors know about anonymous block boxes, and we typically pretend that they aren't there (see percentage resolution, #2595, etc.) So I think we should either
|
When you add |
The big difference is that grid and flex formatting contexts create an anonymous box around each text run. Block formatting contexts only create an anonymous box when there is a mix of inline-level and block-level contents. So saying that anonymous boxes can always be aligned is still not be enough for <div style="width: 200px; justify-items: right; border: solid">foo</div> |
I see, sure. I guess then I'm suggesting that a box should be generated in this case, in order to have consistency. Though I'll admit I don't fully know the side-effects of that. |
I might be missing something, but I think the use of According to 6.1. Inline-Axis (or Main-Axis) Self-Alignment: the justify-self property, |
Yes, that's the current situation, but it seems bad to me. Hence the 2 options I proposed in #11461 (comment): either prevent Note in the 2nd option <!DOCTYPE html>
<div style="justify-items: center; text-align: left; border: solid; width: 200px">
lorem ipsum<br>sit amet
</div> (avoiding the need to add an inner wrapper to get this effect) |
I don't follow. Per the spec:
In particular, the text in How does introducing an anonymous block box here align with the rules for inline formatting contexts? Are you proposing that
I suppose in cases where there are multiple lines of different lengths (e.g., due to a But that feels like a confusing corner case. The box is anonymous, unstyleable, and auto-sized, so people expect no room for alignment to matter. I think discarding alignment properties like |
I'm not proposing to blockify anything.
Yes, the 2nd option avoids establishing an inline formatting context on block containers with
I'm not sure if you are arguing for no change, or for my 1st proposed option. |
Option: "Current" |
IMO The current behaviour in Blink is a bug, and I'd prefer "Option 1" |
But "Option 1" is not compatible with the scenario described in #11461 (comment) |
IMO The current behaviour in Blink is undesirable, and I'd prefer "Option 2". As a web author, I always prefer the more control option. |
I agree that:
|
How is the anonymous block in option 2 sized? |
Yes, both the current Blink behavior and option 2 raise some questions about that. So from an implementation point of view I prefer option 1, which is what I implemented in Servo (I didn't have to do anything special, I just got this behavior due to how we implement anonymous block boxes). Presumably the anonymous box would be sized as <!DOCTYPE html>
<style>
div { float: left; width: 100px; height: 100px;justify-items: right; border: solid; margin: 1em }
div::before { content: ""; display: block }
span { display: inline-block; border: solid magenta }
</style>
<div> <span style="width: 100%; height: 100%"></span> </div>
<div> <span style="width: stretch; height: stretch"></span> </div> So Blink breaks the axis symmetry by allowing percentages and |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
IMO, option 2 feels like a hack. |
Also, I don’t think whether the current Blink behavior is a bug is a matter of opinion but rather it’s a question of whether it conforms to the specification, which it does. While
So it should come as no surprise that an anonymous block box in Blink derives its default value from Similarly, consider how the |
See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53
See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53
See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 Reviewed-by: David Grogan <dgrogan@chromium.org> Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1455957}
See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 Reviewed-by: David Grogan <dgrogan@chromium.org> Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1455957}
See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 Reviewed-by: David Grogan <dgrogan@chromium.org> Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1455957}
…k behaviour., Automatic update from web-platform-tests [align] Tentatively change our anon-block behaviour. See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 Reviewed-by: David Grogan <dgrogan@chromium.org> Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1455957} -- wpt-commits: 188831eade6393b09148089ea030a0e25ef33767 wpt-pr: 52347 Differential Revision: https://phabricator.services.mozilla.com/D248844
…k behaviour., Automatic update from web-platform-tests [align] Tentatively change our anon-block behaviour. See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 Reviewed-by: David Grogan <dgrogan@chromium.org> Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1455957} -- wpt-commits: 188831eade6393b09148089ea030a0e25ef33767 wpt-pr: 52347 Differential Revision: https://phabricator.services.mozilla.com/D248844
You know, we could avoid this whole problem if we go with my earlier interpretation that |
…k behaviour., Automatic update from web-platform-tests [align] Tentatively change our anon-block behaviour. See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 Reviewed-by: David Grogan <dgroganchromium.org> Commit-Queue: Ian Kilpatrick <ikilpatrickchromium.org> Cr-Commit-Position: refs/heads/main{#1455957} -- wpt-commits: 188831eade6393b09148089ea030a0e25ef33767 wpt-pr: 52347 Differential Revision: https://phabricator.services.mozilla.com/D248844 UltraBlame original commit: e52b46cfe8133fe5c42a3cff2a2c795bbacf8710
…k behaviour., Automatic update from web-platform-tests [align] Tentatively change our anon-block behaviour. See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 Reviewed-by: David Grogan <dgroganchromium.org> Commit-Queue: Ian Kilpatrick <ikilpatrickchromium.org> Cr-Commit-Position: refs/heads/main{#1455957} -- wpt-commits: 188831eade6393b09148089ea030a0e25ef33767 wpt-pr: 52347 Differential Revision: https://phabricator.services.mozilla.com/D248844 UltraBlame original commit: e52b46cfe8133fe5c42a3cff2a2c795bbacf8710
…k behaviour., Automatic update from web-platform-tests [align] Tentatively change our anon-block behaviour. See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 Reviewed-by: David Grogan <dgroganchromium.org> Commit-Queue: Ian Kilpatrick <ikilpatrickchromium.org> Cr-Commit-Position: refs/heads/main{#1455957} -- wpt-commits: 188831eade6393b09148089ea030a0e25ef33767 wpt-pr: 52347 Differential Revision: https://phabricator.services.mozilla.com/D248844 UltraBlame original commit: e52b46cfe8133fe5c42a3cff2a2c795bbacf8710
The CSS Working Group just discussed
The full IRC log of that discussion<oriol> https://github.com//issues/11461#issuecomment-2842434810<emilio> oriol: since we resolve justify-self can force fit-content size, if you use justify-items on a block container, a block container with inline level contents, justify-items won't apply <emilio> ... if you then add a block, you add an anonymous block level box and justify-self applies to it <emilio> ... so it's very unexpected that adding a block-level sibling changes the alignment <emilio> ... option 1 would be that anon block boxes would always stretch rather than using justify-items of the parent <emilio> ... another option would be that justify-items other than initial you'd still wrap stuff <emilio> ... IMO option 1 is the easiest to implement in servo, also avoids some questions about what to do with percentages and so on <iank_> +1 Oriol - There is a whole can of worms involved w/ option (2) <emilio> ... percentages in the block axis skips anon boxes, should we skip them in the inline axis if we consider the other option? <emilio> ... miriam preferred option 2 since it's more useful for authors (no need to wrap in implicit elements) <astearns> ack miriam <iank_> q+ <astearns> ack fantasai <emilio> miriam: oriol described what I think, alignment is one of the more common things to do and doing it easily makes sense <fantasai> https://www.w3.org/TR/css-text-4/#text-group-align-property <emilio> .. but either option feels better than the alternative <emilio> fantasai: there's one property that allows you to wrap things, not sure it's implemented <emilio> ... the behavior you want is not the behavior that would fall off from wrapping in anon boxes <emilio> ... consider a paragraph with text, block level, then text <emilio> ... if we wrap each in a box then they'd be independently aligned which I'm not sure is what you want <astearns> ack iank_ <emilio> iank_: pretty against option 2 <emilio> ... quite a large can of worms <emilio> ... probably big source of confusion for web devs too <emilio> ... a little concerned about compat too <emilio> ... so prefer option 1, authors ??? text-align <emilio> astearns: we could resolve on updating the spec to option 1 with a note <emilio> miriam: ok with that <emilio> PROPOSED: Anonymous block boxes always stretch <emilio> RESOLVED: Anonymous block boxes always stretch (go with option 1) |
Under the revised specification, to maintain the layout as it currently appears in Chrome: <!DOCTYPE html>
<div style="justify-items: end;">
A
<div style="background-color: red; width: 50px;">A</div>
B
<div style="background-color: red; width: 50px;">B</div>
C
<div style="background-color: red; width: 50px;">C</div>
</div> We will need to code: <!DOCTYPE html>
<div style="justify-items: end; text-align: right;">
A
<div style="background-color: green; text-align: left; width: 50px;">A</div>
B
<div style="background-color: green; text-align: left; width: 50px;">B</div>
C
<div style="background-color: green; text-align: left; width: 50px;">C</div>
</div> Because apparently, under the current behavior, text node alignment is an exercise in unpredictability, as seen in cases like:
<!DOCTYPE html>
<div>
A
</div> is mutated to: <!DOCTYPE html>
<div style="justify-items: end;">
A
<div>B</div>
</div>
<!DOCTYPE html>
<div style="justify-items: end;">
<div>B</div>
</div> is mutated to: <!DOCTYPE html>
<div style="justify-items: end;">
A
<div>B</div>
</div> In both scenarios, A and B align the same way, which is, of course, totally not what everyone expected. Or not. Interesting. |
<!DOCTYPE html>
<div style="justify-items: end;">
<div>A</div>
<div style="background-color: red; width: 50px;">A</div>
<div>B</div>
<div style="background-color: red; width: 50px;">B</div>
<div>C</div>
<div style="background-color: red; width: 50px;">C</div>
</div> |
CSSWG resolution on Option (1) - the behaviour we changed to in: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 w3c/csswg-drafts#11461 (comment) Make test added in that patch non-tentative. Fixed: 417734173 Change-Id: I4af723d2b39764c77507be038c31214da42f1c69 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6548615 Commit-Queue: Morten Stenshorne <mstensho@chromium.org> Reviewed-by: Morten Stenshorne <mstensho@chromium.org> Auto-Submit: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1460363}
CSSWG resolution on Option (1) - the behaviour we changed to in: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 w3c/csswg-drafts#11461 (comment) Make test added in that patch non-tentative. Fixed: 417734173 Change-Id: I4af723d2b39764c77507be038c31214da42f1c69 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6548615 Commit-Queue: Morten Stenshorne <mstensho@chromium.org> Reviewed-by: Morten Stenshorne <mstensho@chromium.org> Auto-Submit: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1460363}
CSSWG resolution on Option (1) - the behaviour we changed to in: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 w3c/csswg-drafts#11461 (comment) Make test added in that patch non-tentative. Fixed: 417734173 Change-Id: I4af723d2b39764c77507be038c31214da42f1c69 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6548615 Commit-Queue: Morten Stenshorne <mstensho@chromium.org> Reviewed-by: Morten Stenshorne <mstensho@chromium.org> Auto-Submit: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1460363}
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…k behaviour., Automatic update from web-platform-tests [align] Tentatively change our anon-block behaviour. See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 Reviewed-by: David Grogan <dgrogan@chromium.org> Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1455957} -- wpt-commits: 188831eade6393b09148089ea030a0e25ef33767 wpt-pr: 52347 Differential Revision: https://phabricator.services.mozilla.com/D248844
TL;DR: see proposals and comparison
In Blink it looks like this:
In the 1st case, there is no block-level child to align. In the 2nd case, "foo" gets wrapped inside an anonymous block, which is then aligned by
justify-items: right
.But it seems potentially unexpected that appending a block affects the alignment of the inline contents.
Maybe anonymous blocks should get assigned
justify-self: start
justify-self: stretch
(ornormal
)?The text was updated successfully, but these errors were encountered: