8000 csswg-drafts/css3-grid-align/Overview.html at 51172861a34da86d42d2c54fd3097074f5720625 · simonwuelker/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
executable file
·
1913 lines (1796 loc) · 109 KB

File metadata and controls

executable file
·
1913 lines (1796 loc) · 109 KB
<!DOCTYPE HTML>
<html dir="ltr" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>CSS Grid Alignment Level 3</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--
=== NOTA BENE ===
For the three scripts below, if your spec resides on dev.w3 you can check them
out in the same tree and use relative links so that they'll work offline,
-->
<link href="http://dev.w3.org/csswg/default.css" rel="stylesheet" type="text/css" />
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED.css" rel="Stylesheet" type="text/css" />
<style type="text/css">
.example { clear:both; }
</style>
</head>
<body>
<div class="head">
<p><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home" alt="W3C" width="72" height="48"></a></p>
<h1 class="title" id="title">CSS Grid Alignment Level 3</h1>
<h2 id="w3c-editor-s-draft-8-march-2011">W3C Editor's Draft 8 March 2011</h2>
<dl>
<dt>This version:</dt><dd><a href="http://dev.w3.org/csswg/css3-grid-align/">http://dev.w3.org/csswg/css3-grid-align/</a></dd>
<dt>Latest published version:</dt><dd>none</dd>
<dt>Latest editor's draft:</dt><dd><a href="http://dev.w3.org/csswg/css3-grid-align/">http://dev.w3.org/csswg/css3-grid-align/</a></dd>
<dt>Previous version:</dt><dd>none</dd>
<dt>Editors:</dt>
<dd><a href="mailto:alexmog@microsoft.com">Alex Mogilevsky</a>, Microsoft Corporation</dd>
<dd><a href="mailto:pcupp@microsoft.com">Phil Cupp</a>, Microsoft Corporation</dd>
<dd><a href="mailto:mmielke@microsoft.com">Markus Mielke</a>, Microsoft Corporation</dd>
<dd><a href="mailto:daniel.glazman@disruptive-innovations.com">Daniel Glazman</a>, Disruptive Innovations</dd>
</dl>
<p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2010 <a href="http://www.w3.org/"><acronym title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of Technology">MIT</acronym></a>, <a href="http://www.ercim.eu/"><acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p>
<hr />
</div>
<div class="introductory section" id="abstract"><h2>Abstract</h2>
<p>
CSS Grid Alignment Level 3 contains features targeted at web application authors.
The Grid can be used to achieve many different layouts. It excels at dividing
up space for major regions of an application, or defining the relationship in terms of
size, position, and layer between parts of a control built from HTML primitives.
</p>
<p>
Like tables, the Grid enables an author to align elements into columns and rows,
but unlike tables, the Grid doesn't have content structure, and thus enables a wide
variety of layouts not possible with tables. For example, the children of the Grid
can position themselves with <a href="#grid-line">Grid Line</a>s such that they overlap and layer similar to
positioned elements.
</p>
<p>
In addition, the absence of content structure in the Grid helps to manage changes to layout
by using fluid and source order independent lay out techniques. By combining media queries
with the CSS properties that control layout of the Grid and its children, authors can adapt
their layout to changes in device form factors, orientation, and available space, without needing to
alter the semantic nature of their content.
</p>
</div>
<div id="sotd" class="introductory section">
<h2>Status of This Document</h2>
<p>
<em>
This section describes the status of this document at the time of its
publication. Other documents may supersede this document. A list of
current W3C publications and the latest revision of this technical
report can be found in the <a href="http://www.w3.org/TR/">W3C technical reports index</a>
at http://www.w3.org/TR/.
</em>
</p>
<p>
This document was published by the
<a href="http://www.w3.org/Style/CSS/members">CSS Working Group</a> as an Editor's Draft.
If you wish to make comments regarding this document, please send them to
<a href="mailto:www-style@w3.org">www-style@w3.org</a>
(<a href="mailto:www-style-request@w3.org?subject=subscribe">subscribe</a>, <a href="http://lists.w3.org/Archives/Public/www-style/">archives</a>).
All feedback is welcome.
</p>
<p>
Publication as a Editor's Draft does not imply endorsement by the W3C Membership.
This is a draft document and may be updated, replaced or obsoleted by
other documents at any time. It is inappropriate to cite this document
as other than work in progress.
</p>
<p>
This document was produced by a group operating under the
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/" rel="disclosure">public list of any patent disclosures</a>
made in connection with the deliverables of the group; that page also
includes instructions for disclosing a patent. An individual who has
actual knowledge of a patent which the individual believes contains
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must
disclose the information in accordance with
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.
</p>
</div>
<div class="section" id="toc">
<h2 class="introductory">Table of Contents</h2>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#dependencies"><span class="secno">1. </span>Dependencies on other modules</a></li>
<li class="tocline"><a class="tocxref" href="#Introduction"><span class="secno">2. </span>Introduction</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#basic-capabilities"><span class="secno">2.1 </span>Basic Capabilities of the Grid</a></li>
<li class="tocline"><a class="tocxref" href="#adapting-to-available-space"><span class="secno">2.2 </span>Adapting Layouts to Available Space</a></li>
<li class="tocline"><a class="tocxref" href="#source-independence"><span class="secno">2.3 </span>Source Independence</a></li>
<li class="tocline"><a class="tocxref" href="#grid-layering-of-elements"><span class="secno">2.4 </span>Grid Layering of Elements</a></li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#grid-concepts"><span class="secno">3. </span>Core Concepts of the Grid</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#grid-concepts-tracks"><span class="secno">3.1 </span>Grid Tracks</a></li>
<li class="tocline"><a class="tocxref" href="#grid-concepts-lines"><span class="secno">3.2 </span>Grid Lines</a></li>
<li class="tocline"><a class="tocxref" href="#grid-concepts-cells"><span class="secno">3.3 </span>Grid Cells</a></li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#grid-declaration"><span class="secno">4. </span>Grid Declaration</a></li>
<li class="tocline"><a class="tocxref" href="#grid-items"><span class="secno">5. </span>Grid Items</a></li>
<li class="tocline"><a class="tocxref" href="#defining-grid-rows-columns-and-lines"><span class="secno">6. </span>Defining Grid Rows, Columns and Lines</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#grid-rows-columns-and-implicit-grid-lines"><span class="secno">6.1 </span>Grid Rows, Columns and Implicit Grid Lines</a></li>
<li class="tocline"><a class="tocxref" href="#grid-named-grid-lines"><span class="secno">6.2 </span>Named Grid Lines</a></li>
<li class="tocline"><a class="tocxref" href="#grid-starting-and-ending-lines"><span class="secno">6.3 </span>Starting and Ending Grid Lines</a></li>
<li class="tocline"><a class="tocxref" href="#grid-repeating-columns-and-rows"><span class="secno">6.4 </span>Repeating Columns and Rows</a></li>
<li class="tocline"><a class="tocxref" href="#grid-columns-and-rows-properties"><span class="secno">6.5 </span>Grid-columns and Grid-rows Properties</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#fraction-values-fr"><span class="secno">6.5.1 </span>Fraction Values: 'fr'</a></li>
<li class="tocline"><a class="tocxref" href="#computed-values-grid-rows-and-columns"><span class="secno">6.5.2 </span>Computed Values for Grid-rows and Grid-columns</a></li>
</ul>
</li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#grid-item-placement"><span class="secno">7. </span>Placing Grid Items</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#anonymous-grid-cells"><span class="secno">7.1 </span>Anonymous Grid Cells</a></li>
<li class="tocline"><a class="tocxref" href="#explicitly-defined-grid-cells"><span class="secno">7.2 </span>Explicitly Defined Grid Cells</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#grid-cell-pseudo-element-selector"><span class="secno">7.2.1 </span>Grid Cell Psuedo-element Selector</a></li>
<li class="tocline"><a class="tocxref" href="#grid-cell-property-section"><span class="secno">7.2.2 </span>Grid-cell Property</a></li>
<li class="tocline"><a class="tocxref" href="#grid-cell-stacking-property-section"><span class="secno">7.2.3 </span>Grid-cell-stacking Property</a></li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#defining-grid-cells-with-a-template"><span class="secno">7.3 </span>Defining Grid Cells with a Template</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#grid-template-property-section"><span class="secno">7.3.1 </span>Grid-template Property</a></li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#grid-row-span-and-grid-column-span"><span class="secno">7.4 </span>Grid-row-span and Grid-column-span</a></li>
<li class="tocline"><a class="tocxref" href="#grid-implicit-columns-and-rows"><span class="secno">7.5 </span>Implicit Columns and Rows</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#defining-default-size-for-implicit-columns-and-rows"><span class="secno">7.5.1 </span>Defining a Default Size for Implicit Columns and Rows</a></li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#automatic-placement-of-grid-items"><span class="secno">7.6 </span>Automatic Placement of Grid Items</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#automatic-grid-item-placement-algorithm"><span class="secno">7.6.1 </span>Automatic Grid Item Placement Algorithm</a></li>
</ul>
</li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#grid-item-alignment"><span class="secno">8. </span>Grid Item Alignment</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#grid-item-alignment-and-overflow"><span class="secno">8.1 </span>Grid Item Alignment and Overflow</a></li>
</ul>
</li>
<li class="tocline"><a class="tocxref" href="#drawing-order-of-grid-items"><span class="secno">9. </span>Drawing Order of Grid Items</a></li>
<li class="tocline"><a class="tocxref" href="#acknowledgements"><span class="secno">A. </span>Acknowledgements</a></li>
<li class="tocline"><a class="tocxref" href="#references"><span class="secno">B. </span>References</a>
<ul class="toc">
<li class="tocline"><a class="tocxref" href="#normative-references"><span class="secno">B.1 </span>Normative references</a></li>
<li class="tocline"><a class="tocxref" href="#informative-references"><span class="secno">B.2 </span>Informative references</a></li>
</ul>
</li>
</ul>
</div>
<div id="dependencies" class="section">
<h2><span class="secno">1. </span>Dependencies on other modules</h2>
<p>
This CSS3 module depends on the following other CSS3 modules:
</p>
<ul>
<li>TBD</li>
</ul>
<p>
This CSS3 module has normative references to the following other CSS3 modules:
</p>
<ul>
<li>[<cite><a href="#bib-CSS3VAL" rel="biblioentry" class="bibref">CSS3VAL</a></cite>]</li>
<li>[<cite><a href="#bib-CSS3WRITINGMODES" rel="biblioentry" class="bibref">CSS3WRITINGMODES</a></cite>]</li>
</ul>
<p>
This CSS3 module has non-normative (informative) references to the following other CSS3 modules:
</p>
<ul>
<li>[<cite><a href="#bib-CSS3COL" rel="biblioentry" class="bibref">CSS3COL</a></cite>]</li>
<li>[<cite><a href="#bib-CSS3GCPM" rel="biblioentry" class="bibref">CSS3GCPM</a></cite>]</li>
<li>[<cite><a href="#bib-CSS3LAYOUT" rel="biblioentry" class="bibref">CSS3LAYOUT</a></cite>]</li>
</ul>
</div>
<div id="Introduction" class="section">
<h2><span class="secno">2. </span>Introduction</h2>
<div id="basic-capabilities" class="section">
<h3><span class="secno">2.1 </span>Basic Capabilities of the Grid</h3>
<div class="sidefigure">
<img class="figure" alt="Image: Application layout example requiring horizontal and vertical alignment." src="files/basic-form.png" />
<p class="caption">Application layout example requiring horizontal and vertical alignment.</p>
</div>
<p>
As websites evolved from simple documents into complex, interactive applications, tools for document lay out, e.g. floats, were not necessarily well suited for application lay out. By using a combination of tables, JavaScript, or careful measurements on floated elements, authors discovered workarounds to achieve desired layouts. Layouts that adapted to the available space were often brittle and resulted in counter-intuitive behavior as space became constrained. As an alternative, authors of many web applications opted for a fixed layout that cannot take advantage of changes in the available rendering space on a screen.
</p>
<p>
The lay out capabilities of the Grid address these problems. The Grid provides a mechanism for authors to divide available space for lay out into columns and rows using a set of predictable sizing behaviors. Authors can then precisely position and size the building block elements of their application by referencing the <a href="#grid-line">Grid Line</a>s between the columns and rows, or by defining and referencing a <a href="#grid-cell">Grid Cell</a>, which is a rectangular space covering an intersection of columns and rows. Figure 1 illustrates a basic layout which can be achieved with the Grid.
</p>
<!--End Section: Basic Capabilities of the Grid-->
</div>
<div id="adapting-to-available-space" class="section">
<h3><span class="secno">2.2 </span>Adapting Layouts to Available Space</h3>
<div class="sidefigure">
<p>
<img alt="Image: Five grid items arranged according to content size and available space." src="files/game-smaller.png" />
</p>
<p class="caption">Five grid items arranged according to content size and available space.</p>
</div>
<div class="sidefigure">
<p>
<img alt="Image: Growth in the grid due to an increase in available space." src="files/game-larger.png" />
</p>
<p class="caption">Growth in the grid due to an increase in available space.</p>
</div>
<p>
The <a href="#grid-element">Grid element</a> can be used to intelligently reflow elements within a webpage.
Figure 2 represents a game with five major areas in the layout: the game title, stats area, game board, score area, and control area.
The author's intent is to divide the space for the game such that:
</p><ul>
<li>The stats area always appears immediately under the game title.</li>
<li>The game board appears to the right of the stats and title.</li>
<li>The top of the game title and the game board should always align.</li>
<li>The bottom of the game board and the stats area align when the game has reached its minimum height,
but otherwise the game board will stretch to take advantage of all the screen real-estate available to it.
</li>
<li>The score area should align into the column created by the game and stats area, while the controls are centered under the board.</li>
</ul>
<p>
As an alternative to using script to control the absolute position, width, and height of all elements, the author can use the <a href="#grid-element">Grid element</a>, as shown in Figure 3.
The following example shows how an author might achieve all the sizing, placement, and alignment rules declaratively.
</p>
<p>
Note that there are multiple ways to specify the structure of the <a href="#grid-element">Grid</a> and to position and size <a href="#grid-item">Grid Item</a>s, each optimized for different scenarios.
This example illustrates one that an author may use to define the position and space for each <a href="#grid-item">Grid Item</a> using the
<a href="#grid-rows-property"><code>grid-rows</code></a> and <a href="#grid-columns-property"><code>grid-columns</code></a> properties of the <a href="#grid-element">Grid element</a>,
and the <a href="#grid-row-property"><code>grid-row</code></a>, <a href="#grid-column-property"><code>grid-column</code></a>, <a href="#grid-row-span-property"><code>grid-row-span</code></a> and <a href="#grid-column-span-property"><code>grid-column-span</code></a> properties on each <a href="#grid-item">Grid Item</a>.
</p>
<pre class="example">&lt;style type="text/css"&gt;
#grid { display: grid;
/* Two columns: the first sized to content, the second receives the remaining space, */
/* but is never smaller than the minimum size of the board or the game controls, which */
/* occupy this column. */
grid-columns: auto minmax(min-content, 1fr);
/* Three rows: the first and last sized to content, the middle row receives the remaining */
/* space, but is never smaller than the minimum height of the board or stats areas. */
grid-rows: auto minmax(min-content, 1fr) auto
}
/* Each part of the game is positioned between grid lines by referencing the starting grid line and */
/* then specifying, if more than one, the number of rows or columns spanned to determine the ending */
/* grid line, which establishes bounds for the part. */
#title { grid-column: 1; grid-row: 1 }
#score { grid-column: 1; grid-row: 3 }
#stats { grid-column: 1; grid-row: 2; grid-row-align: start }
#board { grid-column: 2; grid-row: 1; grid-row-span: 2 }
#controls { grid-column: 2; grid-row: 2; grid-column-align: center }
&lt;/style&gt;
&lt;div id="grid"&gt;
&lt;div id="title"&gt;Game Title&lt;/div&gt;
&lt;div id="score"&gt;Score&lt;/div&gt;
&lt;div id="stats"&gt;Stats&lt;/div&gt;
&lt;div id="board"&gt;Board&lt;/div&gt;
&lt;div id="controls"&gt;Controls&lt;/div&gt;
&lt;/div&gt;</pre>
<!--End Section: Adapting to Available Space for Layout-->
</div>
<div class="section" id="source-independence">
<h3><span class="secno">2.3 </span>Source Independence</h3>
<div class="sidefigure">
<p>
<img alt="Image: An arrangement suitable for 'portrait' orientation." src="files/game-portrait.png" />
</p>
<p class="caption">An arrangement suitable for 'portrait' orientation.</p>
</div>
<div class="sidefigure">
<p>
<img alt="Image: An arrangment suitable for 'landscape' orientation." src="files/game-landscape.png" />
</p>
<p class="caption">An arrangment suitable for 'landscape' orientation.</p>
</div>
<p>
Continuing the prior example, the author also wants the game to adapt to the space available on traditional computer monitors, handheld devices,
or tablet computers. Also, the game should optimize the placement of the components when viewed either in landscape or portrait orientation
(Figures 4 and 5). By combining the CSS markup for the <a href="#grid-element">Grid element</a> with media queries, the author is able to use
the same semantic markup, but rearranged independent of its source order, to achieve the desired layout in both orientations.
</p>
<p>
The following example leverages the <a href="#grid-element">Grid</a>'s ability to name the space which will be occupied by a <a href="#grid-item">Grid Item</a>. This allows the author
to avoid rewriting rules for <a href="#grid-item">Grid Item</a>s as the <a href="#grid-element">Grid</a>'s definition changes.
</p>
<pre class="example">&lt;style type="text/css"&gt;
@media (orientation: portrait) {
#grid {
display: grid;
/* The rows, columns and cells of the grid are defined visually using the grid-template property. */
/* Each string is a row, and each letter a cell. The max number of letters in any one string determines */
/* the number of columns. */
grid-template: "ta"
"sa"
"bb"
"cc";
/* Columns and rows created with the template property can be assigned a sizing function with the */
/* grid-columns and grid-rows properties. */
grid-columns: auto minmax(min-content, 1fr);
grid-rows: auto auto minmax(min-content, 1fr) auto
}
}
@media (orientation: landscape) {
#grid {
display: grid;
/* Again the template property defines cells of the same name, but this time positioned differently */
/* to better suit a landscape orientation. */
grid-template: "tb"
"ab"
"sc";
grid-columns: auto minmax(min-content, 1fr);
grid-rows: auto minmax(min-content, 1fr) auto
}
}
/* The grid-cell property places a grid item into named region (cell) of the grid. */
#title { grid-cell: "t" }
#score { grid-cell: "s" }
#stats { grid-cell: "a" }
#board { grid-cell: "b" }
#controls { grid-cell: "c" }
&lt;/style&gt;
&lt;div id="grid"&gt;
&lt;div id="title"&gt;Game Title&lt;/div&gt;
&lt;div id="score"&gt;Score&lt;/div&gt;
&lt;div id="stats"&gt;Stats&lt;/div&gt;
&lt;div id="board"&gt;Board&lt;/div&gt;
&lt;div id="controls"&gt;Controls&lt;/div&gt;
&lt;/div&gt;</pre>
<!--End Section: Source Independence-->
</div>
<div class="section" id="grid-layering-of-elements">
<h3><span class="secno">2.4 </span>Grid Layering of Elements</h3>
<div class="sidefigure">
<p>
<img alt="Image: A control composed of layered HTML elements." src="files/control-layering-and-alignment.png" />
</p>
<p class="caption">A control composed of layered HTML elements.</p>
</div>
<p>
In the example shown in Figure 6, the author is creating a custom slider control.
The control has six parts. The lower and upper labels align to the left and right edges of the control.
The track of the slider spans the area between the labels.
The lower and upper fill parts touch beneath the thumb, and the thumb is a fixed width and height
that can be moved along the track by updating the two fraction-sized columns.
</p>
<p>
Prior to the <a href="#grid-element">Grid element</a>, the author would have likely used absolute positioning to control the top and left coordinates,
along with the width and height of each HTML element that comprises the control.
The <code>z-index</code> property would have been used to control element drawing order.
By leveraging the <a href="#grid-element">Grid element</a>, the author can instead limit script usage to handling mouse events on the thumb,
which snaps to various positions along the track as the <a href="#grid-column-property"><code>grid-columns</code></a> property of the <a href="#grid-element">Grid element</a> is updated.
The <a href="#grid-layer-property"><code>grid-layer</code></a> property provides capabilities which are analagous to <code>z-index</code> for <a href="#grid-item">Grid Item</a>s.
</p>
7DDD <pre class="example">&lt;style type="text/css"&gt;
#grid {
display: grid;
/* The grid-columns and rows properties also support naming grid lines which can then be used */
/* to position grid items. The line names are assigned on either side of a column or row */
/* sizing function where the line would logically exist. */
grid-columns:
"start" auto
"track-start" 0.5fr
"thumb-start" auto
"fill-split" auto
"thumb-end" 0.5fr
"track-end" auto
"end";
}
/* Grid-column and grid-row accept a starting and optional endling line. Below the lines are referred to by name. */
/* Beyond any semantic advantage, the names also allow the author to avoid renumbering the grid-row and column */
/* properties of the grid items. This is similar to the concept demonstrated in the prior example with the */
/* grid-template property during orientation changes, but grid lines can also work with layered grid items that */
/* have overlapping cells of different shapes like the thumb and track parts in this example. */
#lower-label { grid-column: "start" }
#track { grid-column: "track-start" "track-end"; grid-row-align: center }
#upper-label { grid-column: "track-end"; }
/* Fill parts are drawn above the track so set grid-layer to 5. */
#lower-fill { grid-column: "track-start" "fill-split"; grid-row-align: center; grid-layer: 5 }
#upper-fill { grid-column: "fill-split" "track-end"; grid-row-align: center; grid-layer: 5 }
/* Thumb is the topmost part; assign it the highest grid-layer value. */
#thumb { grid-column: "thumb-start" "thumb-end"; grid-layer: 10 }
&lt;/style&gt;
&lt;div id="grid"&gt;
&lt;div id="lower-label"&gt;Lower Label&lt;/div&gt;
&lt;div id="upper-label"&gt;Upper Label&lt;/div&gt;
&lt;div id="track"&gt;Track&lt;/div&gt;
&lt;div id="lower-fill"&gt;Lower Fill&lt;/div&gt;
&lt;div id="upper-fill"&gt;Upper Fill&lt;/div&gt;
&lt;div id="thumb"&gt;Thumb&lt;/div&gt;
&lt;/div&gt;</pre>
<!--End Section: Grid Layering of Elements-->
</div>
<!--End Section: Introduction-->
</div>
<div id="grid-concepts" class="section">
<h2><span class="secno">3 </span>Core Concepts of the Grid</h2>
<div class="sidefigure">
<img class="figure" alt="Image: A diagram illustrating the relationship between the Grid Element and its Tracks, Lines, Cells and Items." src="files/grid-concepts.png" />
<p class="caption">A diagram illustrating the relationship between the <a href="#grid-element">Grid element</a> and its Tracks, Lines, Cells and Items.</p>
</div>
<p>
A <dfn id="grid-element">Grid element</dfn> is declared in markup by setting the display property of an element to 'grid'. Child elements of the Grid are termed <a href="#grid-item">Grid Item</a>s and may be positioned and sized by the <a href="#grid-element">Grid element</a> by leveraging the following logical concepts.
</p>
<ul>
<li>Grid Tracks</li>
<li>Grid Lines</li>
<li>Grid Cells</li>
</ul>
<p>
Figure 7 illustrates the relationship between these concepts and the markup in the subsections that follow produce the result shown in the figure.
</p>
<div id="grid-concepts-tracks" class="section">
<h4><span class="secno">3.1 </span>Grid Tracks</h4>
<p>
<dfn id="grid-track">Grid Tracks</dfn> are the columns and rows of the Grid defined with the <a href="#grid-rows-property"><code>grid-rows</code></a> and <a href="#grid-columns-property"><code>grid-columns</code></a> properties on the <a href="#grid-element">Grid element</a>. Each Track is defined by declaring a sequential list of sizing functions, one for each Track. Tracks define the space between <a href="#grid-line">Grid Line</a>s.
</p>
<pre class="example">&lt;style type="text/css"&gt;
#grid {
display: grid;
grid-columns: 150px 1fr; /* two columns */
grid-rows: 50px 1fr 50px /* three rows */
}
&lt;/style&gt;</pre>
<!--End Section: Grid Tracks-->
</div>
<div id="grid-concepts-lines" class="section">
<h4><span class="secno">3.2 </span>Grid Lines</h4>
<p>
<dfn id="grid-line">Grid Lines</dfn> are the horizontal or vertical dividing lines that exist on either side of a column or row. <a href="#grid-line">Grid Line</a>s may be referred to by their <a href="#grid-line">Grid Line</a> number, or they may be named by the author. Authors use one or more quoted strings to assign names to a Line before or after a Track definition wherever the desired Line would logically exist. A <a href="#grid-item">Grid Item</a> then uses the <a href="#grid-line">Grid Line</a>s to determine its position and available space within the Grid by referencing the <a href="#grid-line">Grid Line</a>s using the properties <a href="#grid-row-property"><code>grid-row</code></a> and <a href="#grid-column-property"><code>grid-column</code></a>. <a href="#grid-row-property"><code>Grid-row</code></a> and <a href="#grid-column-property"><code>grid-column</code></a> accept a starting and optional ending Line.
</p>
<p>
The following two examples create three column Grid Lines and four row <a href="#grid-line">Grid Line</a>s. The first example demonstrates how an author would refer to the <a href="#grid-line">Grid Line</a>s using <a href="#grid-line">Grid Line</a> numbers. The second example uses explicitly named <a href="#grid-line">Grid Line</a>s.
</p>
<pre class="example">&lt;style type="text/css"&gt;
#grid {
display: grid;
grid-columns: 150px 1fr;
grid-rows: 50px 1fr 50px
}
#item1 { grid-column: 2; grid-row: 1 4 }
&lt;/style&gt;</pre>
<pre class="example">&lt;style type="text/css"&gt;
/* equivalent layout to the prior example, but using named lines */
#grid {
display: grid;
grid-columns: 150px "item1-start" 1fr "item1-end";
grid-rows: "item1-start" 50px 1fr 50px "item1-end"
}
#item1 {
grid-column: "item1-start" "item1-end";
grid-row: "item1-start" "item1-end"
}
&lt;/style&gt;</pre>
<!--End Section: Grid Lines-->
</div>
<div id="grid-concepts-cells" class="section">
<h4><span class="secno">3.3 </span>Grid Cells</h4>
<p>
<dfn id="grid-cell">Grid Cells</dfn> are the logical space used to lay out one or more <a href="#grid-item">Grid Item</a>s. <a href="#grid-cell">Grid Cell</a>s may be defined explicitly using the <a href="#grid-template-property"><code>grid-template</code></a> property or the <a href="#grid-cell-pseudo-element-selector"><code>grid-cell pseudo-element</code></a>. The <a href="#grid-cell-pseudo-element-selector"><code>grid-cell pseudo-element</code></a> uses a functional syntax which accepts a string name for the Cell. The space for the explicitly defined Cell is then defined by referencing <a href="#grid-line">Grid Line</a>s. When a <a href="#grid-cell">Grid Cell</a> is explicitly defined, multiple <a href="#grid-item">Grid Item</a>s may be stacked or layered into the same <a href="#grid-cell">Grid Cell</a>. When a <a href="#grid-item">Grid Item</a> refers to <a href="#grid-line">Grid Line</a>s directly, an anonymous <a href="#grid-cell">Grid Cell</a> is created which contains only the single <a href="#grid-item">Grid Item</a>.
</p>
<pre class="example">&lt;style type="text/css"&gt;
#grid {
display: grid;
grid-columns: 150px "cell-start" 1fr "cell-end";
grid-rows: "cell-start" 50px 1fr 50px "cell-end"
}
#grid::grid-cell("cell") {
grid-column: "cell-start" "cell-end";
grid-row: "cell-start" "cell-end"
}
#item2 { grid-cell: "cell" }
#item3 { grid-cell: "cell" }
&lt;/style&gt;</pre>
<pre class="example">&lt;style type="text/css"&gt;
/* equivalent layout compared to the prior, but using the template syntax */
#grid {
display: grid;
grid-template: "ad"
"bd"
"cd";
grid-columns: 150px 1fr;
grid-rows: 50px 1fr 50px
}
#item2 { grid-cell: "b" }
#item3 { grid-cell: "b" }
&lt;/style&gt;</pre>
<!--End Section: Grid Cells-->
</div>
<!--End Section: Core Concepts of the Grid-->
</div>
<div id="grid-declaration" class="section">
<h2><span class="secno">4. </span>Grid Declaration</h2>
<p>
A <a href="#grid-element">Grid element</a> is declared by setting the display property.
</p>
<table id="display-property" class="propdef">
<tbody>
<tr>
<td>Name:</td>
<td><dfn id="grid-columns">display</dfn></td>
</tr>
<tr>
<td>Value:</td>
<td>
[ ...existing values... | <span class="normref"><strong>grid | inline-grid</strong></span> |
</td>
</tr>
<tr>
<td>Computed value:</td>
<td>specified value</td>
</tr>
</tbody>
</table>
<dl>
<dt><a name="value-def-display-grid">grid</a></dt>
<dd>A value of grid causes an element to display as a block-level <a href="#grid-element">Grid element</a>.</dd>
<dt><a name="value-def-display-inline-grid">inline-grid</a></dt>
<dd>A value of inline-grid causes an element to display as an inline-level <a href="#grid-element">Grid element</a>.</dd>
</dl>
<!--End Section: Grid Declaration-->
</div>
<div id="grid-items" class="section">
<h2><span class="secno">5. </span>Grid Items</h2>
<p>
The <a href="#grid-element">Grid element</a> performs lay out on <a href="#grid-item">Grid Item</a>s. Block-level children, replaced, inline-block children, and atomic, inline-level children of the Grid are considered <a href="#grid-item">Grid Item</a>s.
</p>
<p>
Contiguous runs of non-replaced, inline content are wrapped in an anonymous, block-level box, which is then treated as a <a href="#grid-item">Grid Item</a> for the purposes of Grid lay out.
Out-of-flow elements (except floats, which are out-of-flow, but are irrelevant to Grid lay out since <a href="#grid-item">Grid Item</a>s can't float) leave behind a "placeholder" in their original source location which is treated like a non-replaced, inline element for the purpose of this wrapping.
Any indirect descendants of the <a href="#grid-element">Grid element</a>, including block elements that are contained in inline elements, are not <a href="#grid-item">Grid Item</a>s.
</p>
<p>
The following example produces two <a href="#grid-item">Grid Items</a>: the first <a href="#grid-item">Grid Item</a> is the anonymous block-level box
wrapping the <code>A</code> and the subsequent <code>&lt;span&gt;</code>; the second <a href="#grid-item">Grid Item</a> is created by the block-level box of the <code>C &lt;div&gt;</code>.
</p>
<pre class="example">&lt;div style="display:grid;"&gt;A&lt;span&gt;B&lt;/span&gt;&lt;div&gt;C&lt;/div&gt;&lt;/div&gt;</pre>
<!--End Section: Grid Items-->
</div>
<div class="section" id="defining-grid-rows-columns-and-lines">
<h2><span class="secno">6. </span>Defining Grid Rows, Columns and Lines</h2>
<div class="section" id="grid-rows-columns-and-implicit-grid-lines">
<h3><span class="secno">6.1 </span>Grid Rows, Columns and Implicit Grid Lines</h3>
<div class="sidefigure">
<img class="figure" alt="Image: Grid Lines." src="files/grid-lines.png" />
<p class="caption">Grid Lines.</p>
</div>
<p>
<a href="#grid-element">Grid element</a>s use <a href="#grid-line">Grid Line</a>s to divide their space.  There are two sets of <a href="#grid-line">Grid Line</a>s: one set defined by the columns that run in the direction of block progression, and another orthogonal set defined by rows.  Block progression is a writing-mode term that defines a logical direction.  In English it means vertical.
</p>
<p>
A <a href="#grid-track">Grid Track</a> is a generic term for a column or row which separates two <a href="#grid-line">Grid Line</a>s. Each <a href="#grid-track">Grid Track</a> is assigned a sizing function, which controls how wide or tall the column or row may grow, and thus how far apart two <a href="#grid-line">Grid Line</a>s are.  The sizing function specified can be a length, a percentage of the <a href="#grid-element">Grid element</a>'s size, derived from the contents occupying the column or row, or a proportion of the space which remains in the <a href="#grid-element">Grid element</a>.  In the last case, remaining space refers to the width or height of the <a href="#grid-element">Grid element</a> after accounting for space already consumed by columns and rows sized with a length, percentage or content.  The size can also be specified as a range using a minmax function, which can combine any of the previously mentioned mechanisms to define a min and max size for the column or row.
  </p>
<p>
In the following example there are two columns and three rows.  The first column is 150px wide beginning from the starting edge of the <a href="#grid-element">Grid element</a>'s content box.  The second column uses fractional sizing, which is a function of the remaining space in the Grid.  Its size will vary as the width of the <a href="#grid-element">Grid element</a> changes.  If the used width of the <a href="#grid-element">Grid element</a> is 200px, then the second column 50px wide.  If the used width of the <a href="#grid-element">Grid element</a> is 100px, then the second column is 0px and any content positioned in the column will be overflowing the <a href="#grid-element">Grid element</a>.  Sizing occurs in a similar fashion for the rows.
</p>
<pre class="example">&lt;style type="text/css"&gt;
#grid {
display: grid;
grid-columns: 150px 1fr;
grid-rows: 50px 1fr 50px
}
&lt;/style&gt;</pre>
<!--End Section: Grid Rows, Columns and Implicit Grid Lines-->
</div>
<div class="section" id="grid-named-grid-lines">
<h3><span class="secno">6.2 </span>Named Grid Lines</h3>
<div class="sidefigure">
<img class="figure" alt="Image: Named Grid Lines." src="files/grid-named-lines.png" />
<p class="caption">Named Grid Lines.</p>
</div>
<p>
A <a href="#grid-line">Grid Line</a> exists on either side of a column or row.  The <a href="#grid-line">Grid Line</a> may be named using one or more quoted strings which are positioned in the grid-rows or grid-columns definitions where the <a href="#grid-line">Grid Line</a> would logically occur (in between the sizing functions that define the Grid's columns and rows).  Each name associated with a <a href="#grid-line">Grid Line</a> must be unique for the set of columns or rows.  If the name is specified multiple times in the same column or row definition, it is associated with the first <a href="#grid-line">Grid Line</a> to which the name was assigned. When a name is not specified, <a href="#grid-line">Grid Line</a>s can be referred to in the order which they occur.  The first line is 1, the second 2 and so on.  The next example builds on the prior by assigning each line one or more names.
</p>
<pre class="example">&lt;style type="text/css"&gt;
#grid {
    display: grid;
    grid-columns: "first" "nav" 150px "main" 1fr "last";
    grid-rows: "first" "header" 50px "main" 1fr "footer" 50px "last";
}
&lt;/style&gt;</pre>
<!--End Section: Named Grid Lines-->
</div>
<div class="section" id="grid-starting-and-ending-lines">
<h3><span class="secno">6.3 </span>Starting and Ending Grid Lines</h3>
<p>
In addition to any explicitly named <a href="#grid-line">Grid Line</a>s defined by the author, a <a href="#grid-element">Grid element</a> also has four implicitly defined <a href="#grid-line">Grid Line</a>s: a start and end line for both columns and rows.  The start line is always positioned on the starting edge of the <a href="#grid-element">Grid element</a>'s content box.  The end line is positioned at the ending edge of the <a href="#grid-element">Grid element</a>'s content box, or at the same location as the last explicitly or implicitly defined <a href="#grid-line">Grid Line</a> when it extends past the content box of the <a href="#grid-element">Grid element</a>.
  </p>
<p>
In the following example, the 'end' column <a href="#grid-line">Grid Line</a> is positioned on the ending edge of the <a href="#grid-element">Grid element</a>'s content box.  The 'end' row <a href="#grid-line">Grid Line</a> is positioned past the ending edge in overflow at the same location as the <a href="#grid-line">Grid Line</a> named "last."
</p> 
<pre class="example">&lt;style type="text/css"&gt;
#grid {
    display: grid;
width: auto;
height: 500px;
    grid-columns: 50px 1fr;
    grid-rows: "first" 250px 250px 250px "last";
}
#item {
/* cover explicitly defined columns and rows */
grid-column: 1 3;
grid-row: "first" "last";
/* equivalent (assuming no implicitly created tracks) */
grid-column: start end;
grid-row: start end;
}
&lt;/style&gt;</pre>
<!--End Section: Starting and Ending Grid Lines-->
</div>
<div class="section" id="grid-repeating-columns-and-rows">
<h3><span class="secno">6.4 </span>Repeating Columns and Rows</h3>
<p>
If there are large number of columns or rows that are the same or exhibit a recurring pattern, a repeat syntax can be applied to define the columns or rows in a more compact form.
</p>
<p>
The next two examples are equivalent.  There is a single row, and a pattern of repetitive column <a href="#grid-line">Grid Line</a>s: a 250px column followed by a 10px gutter.  Note that when repeat syntax is used with <a href="#grid-line">Grid Line</a> naming, that the names are assigned to the first occurrence of the pattern.
</p> 
<pre class="example">&lt;style type="text/css"&gt;
#grid {
     display: grid;
    grid-columns: 10px "content" 250px 10px 250px 10px 250px 10px 250px 10px;
    grid-rows: 1fr;
}
/* Equivalent definition. */
#grid {
    display: grid;
    grid-columns: 10px ("content" 250px 10px)[4];
    grid-rows: 1fr;
}
&lt;/style&gt;</pre>
  <!--End Section: Repeating Columns and Rows-->
</div>
<div class="section" id="grid-columns-and-rows-properties">
<h3><span class="secno">6.5 </span>Grid-columns and Grid-rows Properties</h3>
<p>
The following grammar expresses the allowable values for the grid-rows and grid-columns properties.
</p>
<pre>&lt;track-list&gt; => [ &lt;track-group&gt; ]+ | 'none'
&lt;track-group&gt; => [ &lt;string&gt;* '(' &lt;string&gt;* [ &lt;track-minmax&gt; ]+ &lt;string&gt;* ')' [ '[' &lt;positive-number&gt; ']' ]? &lt;string&gt;*
| &lt;string&gt;* &lt;track-minmax&gt; &lt;string&gt;*
&lt;track-minmax&gt; => 'minmax(' &lt;track-breadth&gt; ',' &lt;track-breadth&gt; ')' | 'auto' | &lt;track-breadth&gt;
&lt;track-breadth&gt; => &lt;length&gt; | &lt;percentage&gt; | &lt;fraction&gt; | 'min-content' | 'max-content'</pre>
<p>Where:</p>
<ul>
<li><strong>length</strong> is as defined by CSS3 Values. [<cite><a href="#bib-CSS3VAL" rel="biblioentry" class="bibref">CSS3VAL</a></cite>]</li>
<li><strong>percentage</strong> expresses a size for a <a href="#grid-track">Grid Track</a> as a percentage of the <a href="#grid-element">Grid element</a>'s logical width (for columns) or logical height (for rows).
When the width or height of the <a href="#grid-element">Grid element</a> is undefined, the percentage is ignored and the <a href="#grid-track">Grid Track</a> will be auto-sized.</li>
<li><strong>fraction</strong> is a non-negative floating-point number followed
by 'fr'. Each <code>fraction</code> value takes a share of the remaining space proportional to
its number. See <a href="#fraction-values-fr">fraction values</a> for more details.</li>
<li><strong>max-content</strong> is a keyword which refers to the maximum of the max sizes of <a href="#grid-item">Grid Item</a>s occupying
the <a href="#grid-track">Grid Track</a>.</li>
<li><strong>min-content</strong> is a keyword which refers to the maximum of the min sizes of <a href="#grid-item">Grid Item</a>s occupying
the <a href="#grid-track">Grid Track</a>.</li>
<li><strong>minmax(min, max)</strong> defines a size range. The size used
should be grea A0B2 ter than or equal to <code>min</code> and less than or equal to <code>max</code>. If <code>max</code> &lt; <code>min</code>,
then <code>max</code> is ignored and <code>minmax(min,max)</code> is treated as <code>minmax(min,min)</code>.</li>
<li><strong>fit-content</strong> is equivalent to <code>minmax(min-content, max-content)</code>.</li>
<li><strong>auto</strong> is quivalent to <code>fit-content</code>.</li>
</ul>
<p class="issue">
Flex should also be allowed as a sizing function for a Grid Track. Update the grammar to accept the flex function when the Flexbox spec
stabilizes.
</p>
<table id="grid-columns-property" class="propdef">
<tbody>
<tr>
<td>Name:</td>
<td><dfn id="grid-columns">grid-columns</dfn></td>
</tr>
<tr>
<td>Value:</td>
<td>see grammar above</td>
</tr>
<tr>
<td>Initial:</td>
<td>none</td>
</tr>
<tr>
<td>Applies to:</td>
<td>non-replaced elements with a computed value of 'grid' or 'inline-grid' for display.</td>
</tr>
<tr>
<td>Inherited:</td>
<td>no</td>
</tr>
<tr>
<td>Percentages:</td>
<td>n/a</td>
</tr>
<tr>
<td>Media:</td>
<td>visual, paged</td>
</tr>
<tr>
<td>Computed value:</td>
<td>see text</td>
</tr>
</tbody>
</table>
<table id="grid-rows-property" class="propdef">
<tbody>
<tr>
<td>Name:</td>
<td><dfn id="grid-rows">grid-rows</dfn></td>
</tr>
<tr>
<td>Value:</td>
<td>see grammar above</td>
</tr>
<tr>
<td>Initial:</td>
<td>none</td>
</tr>
<tr>
<td>Applies to:</td>
<td>non-replaced elements with a computed value of 'grid' or 'inline-grid' for display.</td>
</tr>
<tr>
<td>Inherited:</td>
<td>no</td>
</tr>
<tr>
<td>Percentages:</td>
<td>n/a</td>
</tr>
<tr>
<td>Media:</td>
<td>visual, paged</td>
</tr>
<tr>
<td>Computed value:</td>
<td>see text</td>
</tr>
</tbody>
</table>
<p>The following example:</p>
<ul>
<li>Adds one <a href="#grid-line">Grid Line</a> 100 pixels from the 'start' of the grid.</li>
<li>Adds another <a href="#grid-line">Grid Line</a> 1/2 of the remaining space away.</li>
<li>Adds another <a href="#grid-line">Grid Line</a> whose distance from the prior <a href="#grid-line">Grid Line</a> will be based on the maximum content size of elements
occupying the column.</li>
<li>Adds another <a href="#grid-line">Grid Line</a> whose distance from the prior <a href="#grid-line">Grid Line</a> is based on
the minimum content size of all elements occupying the column, or 1/2 the
remaining space, whichever is greater.</li>
</ul>
<pre class="example">div { grid-columns: 100px 1fr max-content minmax(min-content, 1fr) }</pre>
<p>Additional examples of valid <a href="#grid-track">Grid Track</a> definitions:</p>
<pre class="example"> /* examples of valid track definitions */
grid-rows: 1fr minmax(min-content, 1fr);
grid-rows: 10px (1fr auto minmax(30%, 1fr))[2];
grid-rows: (10px);
grid-rows: calc(4em - 5px)</pre>
<!--End Section: Grid-columns and Grid-rows Properties-->
</div>
<div id="fraction-values-fr" class="section">
<h4><span class="secno">6.5.1 </span>Fraction Values: 'fr'</h4>
<p>Fraction values are new units applicable to the <a href="#grid-rows-property">grid-rows</a> and <a href="#grid-columns-property">grid-columns</a> properties:</p>
<dl>
<dt>fr</dt>
<dd>Fraction of available space. </dd>
</dl>
<p>
The distribution of fractional space occurs after all <code>&lt;length&gt;</code>
or content-based row and column sizes have reached their maximum.
The total size of the rows or columns is then subtracted from the available space and the remainder is
divided proportionately among the fractional rows and columns.
</p>
<p>
Each column or row's proportional share can be computed as the column or row's
<code>&lt;fraction&gt; * &lt;remaining space&gt; / &lt;sum of all fractions&gt;</code>.
Note that fractions occurring within a <code>minmax</code> function are only counted in the sum if in the <code>max</code> position.
Further, fractions that occur in the <code>min</code> position are treated as an absolute length of <code>0px</code>.
</p>
<p>
When remaining space cannot be determined because the width or height of the <a href="#grid-element">Grid element</a> is undefined, fraction-sized <a href="#grid-track">Grid Track</a>s
are sized to their contents while retaining their respective proportions. In such cases the size of each fractional <a href="#grid-track">Grid Track</a> can
be computed by determining the <code>max-content</code> size of each fractional <a href="#grid-track">Grid Track</a> and dividing that size by the respective
<code>fraction</code>. The maximum value is of those results is treated as the <code>1fr</code> value, which is then multiplied
by each <a href="#grid-track">Grid Track</a>'s <code>fraction</code> to determine its final size.
</p>
<!--End Section: Fraction Values: 'fr'-->
</div>
<div id="computed-values-grid-rows-and-columns" class="section">
<h4><span class="secno">6.5.2 </span>Computed Values for Grid-rows and Grid-columns</h4>
<p>
The computed size of all <a href="#grid-track">Grid Track</a>s as returned for the grid-rows and grid-columns properties are normalized to used pixel values.
All <a href="#grid-track">Grid Track</a>s are included in the computed value reported for grid-rows and grid-columns regardless of how the <a href="#grid-track">Grid Track</a>s were created, e.g. implicit tracks may be created by <a href="#grid-item">Grid Item</a>s referencing a <a href="#grid-line">Grid Line</a> not explicitly defined by a grid-rows or grid-columns property.
The computed value includes any used values for named lines; any duplicate names must be removed. User agents may use the repeat syntax to avoid expansive string length due to implicit <a href="#grid-track">Grid Track</a> creation,
large spanning values or high repeat counts specified by the author.
</p>
<p>
The algorithm used to apply repeat syntax to used <a href="#grid-track">Grid Track</a> values and <a href="#grid-line">Grid Line</a> names is User agent specific. See below for example inputs and outputs.
</p>
<pre class="example">&lt;style type=&quot;text/css&quot;&gt;
#grid {
width: 500px;
grid-columns: "a" auto "b" minmax(min-content, 1fr) "b" "c" "d" ("e" 40px)[2] (auto)[5];
}
&lt;/style&gt;
&lt;div id=&quot;grid&quot;&gt;
&lt;div style=&quot;grid-column:1; width:50px&quot;&gt;&lt;/div&gt;
&lt;div style=&quot;grid-column:9; width:50px&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
// Returns '"a" 50px "b" 320px "c" "d" ("e" 40px)[2] (0px)[4] 50px'.
window.getComputedStyle(document.getElementById("grid"), null).getPropertyValue("grid-columns")
&lt;/script&gt;</pre>
<!--End Section: Fraction Values: 'fr'-->
</div>
<!--End Section: Defining Grid Rows and Columns-->
</div>
<div id="grid-item-placement" class="section">
<h2><span class="secno">7.</span> Placing Grid Items</h2>
<p>The properties grid-row and grid-column are used to place <a href="#grid-item">Grid Item</a>s and explicitly defined <a href="#grid-cell">Grid Cell</a>s in the Grid.</p>
<table id="grid-column-property" class="propdef">
<tbody>
<tr>
<td>Name:</td>
<td><dfn id="grid-column">grid-column</dfn></td>
</tr>
<tr>
<td>Value:</td>
<td>[ [ &lt;integer&gt; | &lt;string&gt; | 'start' | 'end' ] [ &lt;integer&gt; | &lt;string&gt; | 'start' | 'end' ]? ] | 'auto'</td>
</tr>
<tr>
<td>Initial:</td>
<td>auto</td>
</tr>
<tr>
<td>Applies to:</td>
<td>Grid Item elements</td>
</tr>
<tr>
<td>Inherited:</td>
<td>no</td>
</tr>
<tr>
<td>Percentages:</td>
<td>n/a</td>
</tr>
<tr>
<td>Media:</td>
<td>visual, paged</td>
</tr>
<tr>
<td>Computed value:</td>
<td>see text</td>
</tr>
</tbody>
</table>
<table id="grid-row-property" class="propdef">
<tbody>
<tr>
<td>Name:</td>
<td><dfn id="grid-row">grid-row</dfn></td>
</tr>
<tr>
<td>Value:</td>
<td>[ [ &lt;integer&gt; | &lt;string&gt; | 'start' | 'end' ] [ &lt;integer&gt; | &lt;string&gt; | 'start' | 'end' ]? ] | 'auto'</td>
</tr>
<tr>
<td>Initial:</td>
<td>auto</td>
</tr>
<tr>
<td>Applies to:</td>
<td>Grid Item elements</td>
</tr>
<tr>
<td>Inherited:</td>
<td>no</td>
</tr>
<tr>
<td>Percentages:</td>
<td>n/a</td>
</tr>
<tr>
<td>Media:</td>
<td>visual, paged</td>
</tr>
<tr>
<td>Computed value:</td>
<td>see text</td>
</tr>
</tbody>
</table>
<div id="anonymous-grid-cells" class="section">
<h3><span class="secno">7.1</span> Anonymous Grid Cells</h3>
<p>
<a href="#grid-item">Grid Item</a>s are placed into <a href="#grid-cell">Grid Cell</a>s. A <a href="#grid-cell">Grid Cell</a> defines the available space for a <a href="#grid-item">Grid Item</a>.  The dimensions of the <a href="#grid-cell">Grid Cell</a> are specified by naming the starting and ending lines which define the columns and rows that the <a href="#grid-cell">Grid Cell</a> occupies.  The starting and ending lines may be referred to by a string name, if one was defined by the author, the start and end line keywords, or the <a href="#grid-line">Grid Line</a>'s number.
</p>
<p>
The following example positions the first <a href="#grid-item">Grid Item</a> to cover all rows and columns of the <a href="#grid-element">Grid element</a> using the start and end keywords.  The second <a href="#grid-item">Grid Item</a> is positioned to cover the first row.  Note that when only the starting <a href="#grid-line">Grid Line</a> of the grid-row or grid-column properties are specified for the <a href="#grid-cell">Grid Cell</a>, that the <a href="#grid-cell">Grid Cell</a> is assumed to extend to the subsequent <a href="#grid-line">Grid Line</a>.
</p>
<pre class="example">&lt;style type=&quot;text/css&quot;&gt;
/* covers the <a href="#grid-element">Grid element</a>'s content box */
#item1 {
    grid-row: start end;
    grid-column: start end;
}
 
/* covers the first row */
#item2 {
    grid-row: start; /* extends to row Grid Line 2 */
    grid-column: start end;
}
&lt;/style&gt;</pre>
<p>
The next example defines rows for header and footer <a href="#grid-item">Grid Item</a>s sized to content, as well as a main region that receives all remaining space.   A single column which receives all horizontal space in the Grid's content box is also defined.
</p>
<pre class="example">&lt;style type=&quot;text/css&quot;&gt;