RESOLVED FIXED321024
subgrid columns ignore the parent grid's content distribution
https://bugs.webkit.org/show_bug.cgi?id=321024
Summary subgrid columns ignore the parent grid's content distribution
Pawel Grzybek
Reported 2026-08-04 14:24:18 PDT
Created attachment 480925 [details] A rendering comparison between Chrome, Firefox and Safari There is an issue with rendering CSS subgrids, that also set the justify-content property. Here is an example. ``` <section class="grid"> <div>one</div> <div>two</div> <div>three</div> <section class="subgrid"> <div>one</div> <div>two</div> <div>three</div> </section> </section> ``` ``` .grid { display: grid; grid-template-columns: repeat(3, 25%); gap: 1rem; justify-content: space-between; } .subgrid { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; justify-content: space-between; } ``` Expectation: The subgrid children shold be layed out the same as the top level divs in the parent grid layout. This is not the case in Safari. As per the image below and CodePen attached, Chrome and Frirefox rederes that correctly, Safari ignoores justify content on the subgrids. https://codepen.io/editor/pawelgrzybek/pen/019fcc89-c7a0-7069-9183-4cb470a6b5e5
Attachments
A rendering comparison between Chrome, Firefox and Safari (1.10 MB, image/png)
2026-08-04 14:24 PDT, Pawel Grzybek
no flags
testcase.html (4.64 KB, text/html)
2026-08-17 02:57 PDT, Karl Dubost
no flags
rendering in safari, firefox, chrome (545.13 KB, image/png)
2026-08-17 02:58 PDT, Karl Dubost
no flags
Radar WebKit Bug Importer
Comment 1 2026-08-10 12:21:28 PDT
Karl Dubost
Comment 2 2026-08-17 02:39:08 PDT
some context: > Layoutwise, the subgrid’s grid is always aligned with the corresponding section of the parent grid; the align-content/justify-content properties on it are also ignored in the subgridded dimension. > css-grid-2 §subgrid-grid-alignment https://drafts.csswg.org/css-grid-2/#subgrid-grid-alignment
Karl Dubost
Comment 3 2026-08-17 02:57:58 PDT
Created attachment 481074 [details] testcase.html
Karl Dubost
Comment 4 2026-08-17 02:58:49 PDT
Created attachment 481075 [details] rendering in safari, firefox, chrome Safari Technology Preview 27.0 (Release 250) 22626.1.2.19.2 Firefox Nightly 156.0a1 15626.8.16 Google Chrome Canary 153.0.8009.2 8009.2
Karl Dubost
Comment 5 2026-08-17 05:55:37 PDT
The summary names a declaration that does nothing: justify-content on a subgrid is ignored in a subgridded axis, and WebKit already ignores it correctly. The real failure is the other half of the same spec sentence: the subgrid's grid has to line up with the section of the parent grid it covers. https://drafts.csswg.org/css-grid-2/#subgrid-grid-alignment 400px container, three 25% columns, 16px gap, space-between, so 68px spare and 34px into each gap: col 1 col 2 col 3 parent's children 0 150 300 subgrid's children 0 116 232 116 is 100+16 and 232 is 200+32 -> track plus gap, with the 34 dropped each time. Safari 27.0. Chrome 153 and Firefox 156 both give 0 / 150 / 300. Same failure in rows with align-content, with space-around and space-evenly, with a subgrid over only part of the tracks, and nested. justify-content: center is correct, which locates it: center shifts the whole grid and adds nothing between tracks. Let's retitle to "subgrid columns ignore the parent grid's content distribution". Adding bug 259880 to See Also Same family, different cause, not fixed by this. Patch in progress.
Karl Dubost
Comment 6 2026-08-17 05:59:08 PDT
Karl Dubost
Comment 7 2026-08-17 22:15:33 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/62011
EWS
Comment 8 2026-08-18 00:50:15 PDT
Committed 319353@main (767e62cbb344): <https://commits.webkit.org/319353@main> Reviewed commits have been landed. Closing PR #71768 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.