Title: CSS Grid Layout Module Level 2
Shortname: css-grid
Level: 2
Status: UD
Group: csswg
Work Status: exploring
ED: https://drafts.csswg.org/css-grid-2/
Editor: Tab Atkins Jr., Google, http://www.xanthir.com/contact/
Editor: Elika J. Etemad / fantasai, Invited Expert, http://fantasai.inkedblade.net/contact, w3cid 35400
Editor: Rossen Atanassov, Microsoft, ratan@microsoft.com
Abstract: This CSS module defines a two-dimensional grid-based layout system, optimized for user interface design. In the grid layout model, the children of a grid container can be positioned into arbitrary slots in a predefined flexible or fixed-size layout grid.
Introduction {#intro} ===================== This level is currently maintained as a diff spec over the level 1 module [[!CSS-GRID-1]].

Grid Containers

Establishing Grid Containers: the ''subgrid'' 'display' value

Subgrids provide the ability to pass grid parameters down through nested elements, and content-based sizing information back up to their parent grid.
	Name: display
	New values: subgrid
	
subgrid
If the element is a grid item (i.e. it is in-flow and its parent is a grid container), this value makes the element a subgrid (which is a special type of grid container box, see [[#subgrids]]) and consequently ignores its 'grid-template-*' and 'grid-*-gap' properties in favor of adopting the parent grid tracks that it spans. Otherwise, it behaves as ''grid''.

Subgrids

A grid item can itself be a grid container by giving it ''display: grid''; in this case the layout of its contents will be independent of the layout of the grid it participates in. In some cases it might be necessary for the contents of multiple grid items to align to each other. A grid container that is itself a grid item can defer the definition of its rows and columns to its parent grid container by using ''display: subgrid'', making it a subgrid. In this case, the grid items of the subgrid participate in sizing the grid of the parent grid container, allowing the contents of both grids to align.
For example, suppose we have a form consisting of a list of inputs with labels:
			<ul>
				<li><label>Name:</label> <input name=fn>
				<li><label>Address:</label> <input name=address>
				<li><label>Phone:</label> <input name=phone>
			</ul>
		
We want the labels and inputs to align, and we want to style each list item with a border. This can be accomplished with subgrid layout:
			ul {
				display: grid;
				grid: auto-flow / auto 1fr;
			}
			li {
				display: subgrid;
				grid-column: span 2;
				margin: 0.5em;
				border: solid;
				padding: 0.5em;
			}
			label {
				grid-column: 1;
			}
			input {
				grid-column: 2;
			}
		
A subgrid behaves just like a normal grid container except that:

Masonry Layout

People have been trying to use CSS for masonry layouts for over a decade, and it doesn't seem to have slowed, so it's probably not just a layout fad. Would probably be worthwhile to address officially. As far as I can tell, this is best done as a Grid feature; some of the features I've seen in masonry libraries (like large items spanning multiple masonry tracks) make Flexbox inappropriate. This also would reuse *so many* Grid features that it would be a shame to put together a brand new layout spec for it. No clue what it would look like yet, tho. In handwavey terms, it's a grid that's only gridded "in one dimension", and free-flows in the other, with auto-flow. Note that this is actually 100% possibly with Grid today, if your items are of known height, by making thousands of 1px tall rows, and setting the items' row-span to be equal to their height in px. (Or some lower-res multiple, like 10px rows.) Dense row auto-flow then magically makes Masonry happen. This is just a terrible hack that runs into memory/CPU issues due to the large number of rows. It suggests, tho, that making it work properly is mostly a matter of relaxing some constraints, rather than adding entirely new behavior.