@@ -270,6 +270,8 @@ <h2 class="no-num no-toc" id=contents> Table of contents</h2>
270270
271271 < li > < a href ="#resolved-track-list "> < span class =secno > 5.1.4. </ span >
272272 Resolved Values</ a >
273+
274+ < li > < a href ="#subgrids "> < span class =secno > 5.1.5. </ span > Subgrids</ a >
273275 </ ul >
274276
275277 < li > < a href ="#grid-template-areas-property "> < span class =secno > 5.2.
@@ -959,8 +961,9 @@ <h3 id=grid-containers><span class=secno>3.1. </span> Grid Containers: the
959961 class =css > grid</ code > ’</ a > in the "Computed Value" column.
960962
961963 < h3 id =subgrids-the-subgrid-display-value > < span class =secno > 3.2.
962- </ span > Subgrids: the ‘< code class =css > subgrid</ code > ’ ‘< code
963- class =property > display</ code > ’ value</ h3 >
964+ </ span > Subgrids: the ‘< a href ="#subgrid0 "> < code
965+ class =css > subgrid</ code > </ a > ’ ‘< code class =property > display</ code > ’
966+ value</ h3 >
964967
965968 < div class =issue > This is a proposal to address the alignment of sub-items
966969 across grid items, so that, for example, a grid of labels + inputs (with
@@ -983,74 +986,6 @@ <h3 id=subgrids-the-subgrid-display-value><span class=secno>3.2.
983986 </ ul >
984987 </ div >
985988
986- < p > A < a href ="#grid-item "> < i > grid item</ i > </ a > can itself be a < a
987- href ="#grid-container "> < i > grid container</ i > </ a > by giving it ‘< code
988- class =css > display: grid</ code > ’; in this case the layout of its contents
989- will be independent of the layout of the grid it participates in.
990-
991- < p > In some cases it might be necessary for the contents of multiple < a
992- href ="#grid-item "> < i > grid items</ i > </ a > to align to each other; in this
993- case ‘< code class =css > display: subgrid</ code > ’ can be used. A < a
994- href ="#grid-item "> < i > grid item</ i > </ a > with ‘< code class =css > display:
995- subgrid</ code > ’ behaves just like one with ‘< code class =css > display:
996- grid</ code > ’ except that:
997-
998- < ul >
999- < li > The ‘< a href ="#grid-template-columns "> < code
1000- class =property > grid-template-columns</ code > </ a > ’ and ‘< a
1001- href ="#grid-template-rows "> < code
1002- class =property > grid-template-rows</ code > </ a > ’ properties do not apply.
1003- Instead the number of explicit tracks is given by its < a
1004- href ="#grid-span "> < i > grid span</ i > </ a > .
1005-
1006- < li > The < a href ="#grid-span "> < i > grid span</ i > </ a > of the item is
1007- determined by the number of grid rows and grid columns it contains.
1008-
1009- < li > The < a href ="#grid-placement-properties "> < i > grid-placement
1010- properties</ i > </ a > are scoped to the tracks covered by the subgrid:
1011- numeric indices count starting from the first line of the subgrid rather
1012- than the first line of the parent grid.
1013-
1014- < li > The subgrid's own grid items participate in the sizing of its parent
1015- grid and are aligned to it. In this process, the sum of the item's
1016- margin, padding, and borders are applied as an extra layer of margin to
1017- the items at those edges.
1018- </ ul >
1019-
1020- < div class =example >
1021- < p > For example, suppose we have a form consisting of a list of inputs
1022- with labels:
1023-
1024- < pre >
1025- <ul>
1026- <li> <label> Name:</label> <input name=fn>
1027- <li> <label> Address:</label> <input name=address>
1028- <li> <label> Phone:</label> <input name=phone>
1029- </ul> </ pre >
1030-
1031- < p > We want the labels and inputs to align, and we want to style each list
1032- item with a border. This can be accomplished with subgrid layout:
1033-
1034- < pre >
1035- ul {
1036- display: grid;
1037- grid-auto-flow: rows;
1038- grid-template-columns: auto 1fr;
1039- }
1040- li {
1041- display: subgrid;
1042- margin: 0.5em;
1043- border: solid;
1044- padding: 0.5em;
1045- }
1046- label {
1047- grid-column: 1;
1048- }
1049- input {
1050- grid-column: 2;
1051- }</ pre >
1052- </ div >
1053-
1054989 < h2 id =grid-items > < span class =secno > 4. </ span > Grid Items</ h2 >
1055990
1056991 < p > The contents of a < a href ="#grid-container "> < i > grid container</ i > </ a >
@@ -1250,7 +1185,8 @@ <h3 id=track-sizing><span class=secno>5.1. </span> Track Sizing: the ‘<a
12501185 < tr >
12511186 < td > Value:
12521187
1253- < td > none | < a href ="#lttrack-list "> < var > <track-list> </ var > </ a >
1188+ < td > none | < a href ="#lttrack-list "> < var > <track-list> </ var > </ a > |
1189+ subgrid < a href ="#ltline-names "> < var > <line-names> </ var > </ a > *
12541190
12551191 < tr >
12561192 < td > Initial:
@@ -1380,12 +1316,21 @@ <h3 id=track-sizing><span class=secno>5.1. </span> Track Sizing: the ‘<a
13801316 </ dl >
13811317
13821318 < p > The < dfn id =grid-definition-none > none</ dfn > value indicates that there
1383- is no initial grid; any rows/columns will be implicitly generated, and
1384- their size will be determined by the ‘< a href ="#grid-auto-rows "> < code
1319+ is no < a href ="#explicit-grid "> < i > explicit grid</ i > </ a > ; any rows/columns
1320+ will be implicitly generated, and their size will be determined by the
1321+ ‘< a href ="#grid-auto-rows "> < code
13851322 class =property > grid-auto-rows</ code > </ a > ’ and ‘< a
13861323 href ="#grid-auto-columns "> < code
13871324 class =property > grid-auto-columns</ code > </ a > ’ properties.
13881325
1326+ < p > The < dfn id =subgrid > subgrid</ dfn > value indicates that the grid will
1327+ align to its parent grid in that axis. Rather than specifying the sizes of
1328+ rows/columns explicitly, they'll be taken from the parent grid's
1329+ definition. If the < a href ="#grid-container "> < i > grid container</ i > </ a > is
1330+ not a < a href ="#grid-item "> < i > grid item</ i > </ a > , this value computes to
1331+ ‘< a href ="#none "> < code class =css > none</ code > </ a > ’. See the < a
1332+ href ="#subgrids "> Subgrids</ a > section for more detail.
1333+
13891334 < div class =example >
13901335 < p > Given the following ‘< a href ="#grid-template-columns "> < code
13911336 class =property > grid-template-columns</ code > </ a > ’ declaration:
@@ -1626,6 +1571,121 @@ <h4 id=resolved-track-list><span class=secno>5.1.4. </span> Resolved Values</h4>
16261571 for a small list of legacy 2.1 properties. Do we really want these
16271572 properties to return the used value here?
16281573
1574+ < h4 id =subgrids > < span class =secno > 5.1.5. </ span > Subgrids</ h4 >
1575+
1576+ < p > A < a href ="#grid-item "> < i > grid item</ i > </ a > can itself be a < a
1577+ href ="#grid-container "> < i > grid container</ i > </ a > by giving it ‘< code
1578+ class =css > display: grid</ code > ’; in this case the layout of its contents
1579+ will be independent of the layout of the grid it participates in.
1580+
1581+ < p > In some cases it might be necessary for the contents of multiple < a
1582+ href ="#grid-item "> < i > grid items</ i > </ a > to align to each other. A < a
1583+ href ="#grid-container "> < i > grid container</ i > </ a > that is itself a < a
1584+ href ="#grid-item "> < i > grid item</ i > </ a > can defer the definition of its
1585+ rows or columns to its parent < a href ="#grid-container "> < i > grid
1586+ container</ i > </ a > by using the ‘< a href ="#subgrid0 "> < code
1587+ class =css > subgrid</ code > </ a > ’ keyword in ‘< a
1588+ href ="#grid-template-rows "> < code
1589+ class =property > grid-template-rows</ code > </ a > ’ and/or ‘< a
1590+ href ="#grid-template-columns "> < code
1591+ class =property > grid-template-columns</ code > </ a > ’, making it a < dfn
1592+ id =subgrid0 > subgrid</ dfn > in that dimension. In this case, the < a
1593+ href ="#grid-item "> < i > grid items</ i > </ a > of the < a
1594+ href ="#subgrid0 "> < i > subgrid</ i > </ a > participate in sizing the < a
1595+ href ="#display-grid "> < i > grid</ i > </ a > of the parent < a
1596+ href ="#grid-container "> < i > grid container</ i > </ a > , allowing the contents of
1597+ both grids to align.
1598+
1599+ < p > A < a href ="#subgrid0 "> < i > subgrid</ i > </ a > behaves just like a normal < a
1600+ href ="#grid-container "> < i > grid container</ i > </ a > except that:
1601+
1602+ < ul >
1603+ < li > The number of explicit tracks is given by its < a
1604+ href ="#grid-span "> < i > grid span</ i > </ a > , rather than by ‘< a
1605+ href ="#grid-template-rows "> < code
1606+ class =property > grid-template-rows</ code > </ a > ’/‘< a
1607+ href ="#grid-template-columns "> < code
1608+ class =property > grid-template-columns</ code > </ a > ’. If the < a
1609+ href ="#grid-span "> < i > grid span</ i > </ a > is ‘< a
1610+ href ="#track-size-auto "> < code class =css > auto</ code > </ a > ’, the number of
1611+ tracks is determined by the size of the < a
1612+ href ="#subgrid0 "> < i > subgrid</ i > </ a > ’s < i > implicit grid</ i > , which is
1613+ defined to also be the < a href ="#explicit-grid "> < i > explicit grid</ i > </ a > .
1614+
1615+ < li > The < a href ="#grid-placement-properties "> < i > grid-placement
1616+ properties</ i > </ a > of the < a href ="#subgrid0 "> < i > subgrid</ i > </ a > ’s < a
1617+ href ="#grid-item "> < i > grid items</ i > </ a > are scoped to the lines covered
1618+ by the subgrid. E.g., numeric indices count starting from the first line
1619+ of the subgrid rather than the first line of the parent grid.
1620+
1621+ < li > The < a href ="#subgrid0 "> < i > subgrid</ i > </ a > ‘< code class =css > s own
1622+ grid items participate in the sizing of its parent grid and are aligned
1623+ to it. In this process, the sum of the item</ code > ’s margin, padding,
1624+ and borders are applied as an extra layer of margin to the items at those
1625+ edges.
1626+
1627+ < li > The < a href ="#subgrid0 "> < i > subgrid</ i > </ a > is always stretched; the
1628+ ‘< code class =property > align-self</ code > ’/‘< code
1629+ class =property > justify-self</ code > ’ properties on it are ignored. Any
1630+ specified width/height constraints are also ignored.
1631+
1632+ < li > The < a href ="#subgrid0 "> < i > subgrid</ i > </ a > ’s < a
1633+ href ="#explicit-grid "> < i > explicit grid</ i > </ a > is always aligned with the
1634+ corresponding section of the parent < a
1635+ href ="#display-grid "> < i > grid</ i > </ a > ; the ‘< code
1636+ class =property > align-content</ code > ’/‘< code
1637+ class =property > justify-content</ code > ’ properties on it are ignored.
1638+
1639+ < li > Explicit named lines can also be specified together with the ‘< a
1640+ href ="#subgrid0 "> < code class =css > subgrid</ code > </ a > ’ keyword; these
1641+ names apply to the corresponding lines taken from the parent < a
1642+ href ="#display-grid "> < i > grid</ i > </ a > . If the < a
1643+ href ="#subgrid0 "> < i > subgrid</ i > </ a > has an explicit < a
1644+ href ="#grid-span "> < i > grid span</ i > </ a > , any names for lines beyond the
1645+ span are ignored. If the < a href ="#subgrid0 "> < i > subgrid</ i > </ a > has an
1646+ explicit < i > grid position</ i > as well as an explicit < a
1647+ href ="#grid-span "> < i > grid span</ i > </ a > , it also automatically receives
1648+ the names of the lines that it covers in its parent < a
1649+ href ="#display-grid "> < i > grid</ i > </ a > .
1650+ </ ul >
1651+
1652+ < div class =example >
1653+ < p > For example, suppose we have a form consisting of a list of inputs
1654+ with labels:
1655+
1656+ < pre >
1657+ <ul>
1658+ <li> <label> Name:</label> <input name=fn>
1659+ <li> <label> Address:</label> <input name=address>
1660+ <li> <label> Phone:</label> <input name=phone>
1661+ </ul> </ pre >
1662+
1663+ < p > We want the labels and inputs to align, and we want to style each list
1664+ item with a border. This can be accomplished with subgrid layout:
1665+
1666+ < pre >
1667+ ul {
1668+ display: grid;
1669+ grid-auto-flow: rows;
1670+ grid-template-columns: auto 1fr;
1671+ }
1672+ li {
1673+ display: subgrid;
1674+ margin: 0.5em;
1675+ border: solid;
1676+ padding: 0.5em;
1677+ }
1678+ label {
1679+ grid-column: 1;
1680+ }
1681+ input {
1682+ grid-column: 2;
1683+ }</ pre >
1684+ </ div >
1685+
1686+ < p class =issue > Do we want to allow ‘< code class =css > repeat()</ code > ’
1687+ when specifying named lines for subgrids?
1688+
16291689 < h3 id =grid-template-areas-property > < span class =secno > 5.2. </ span > Named
16301690 Areas: the ‘< a href ="#grid-template-areas "> < code
16311691 class =property > grid-template-areas</ code > </ a > ’ property</ h3 >
@@ -4133,6 +4193,10 @@ <h2 class=no-num id=index> Index</h2>
41334193 title ="section 10.4. "> < strong > 10.4.</ strong > </ a >
41344194 </ ul >
41354195
4196+ < li > subgrid, < a href ="#subgrid "
4197+ title ="section 5.1. "> < strong > 5.1.</ strong > </ a > , < a href ="#subgrid0 "
4198+ title ="section 5.1.5. "> < strong > 5.1.5.</ strong > </ a >
4199+
41364200 < li > <track-breadth> , < a href ="#lttrack-breadth "
41374201 title ="section 5.1. "> < strong > 5.1.</ strong > </ a >
41384202
@@ -4361,7 +4425,7 @@ <h2 class=no-num id=property-index> Property index</h2>
43614425 < th > < a class =property
43624426 href ="#grid-template-columns "> grid-template-columns</ a >
43634427
4364- < td > none | <track-list>
4428+ < td > none | <track-list> | subgrid <line-names > *
43654429
43664430 < td > none
43674431
@@ -4376,7 +4440,7 @@ <h2 class=no-num id=property-index> Property index</h2>
43764440 < tr >
43774441 < th > < a class =property href ="#grid-template-rows "> grid-template-rows</ a >
43784442
4379- < td > none | <track-list>
4443+ < td > none | <track-list> | subgrid <line-names > *
43804444
43814445 < td > none
43824446
0 commit comments