author Alex Mogilevsky <alexmog@microsoft.com>
Sun, 11 Mar 2012 21:15:40 -0700
changeset 4726 53deb8301b61
parent 4725 d3362b8a88c8
child 4728 5ff50322db2c
permissions -rw-r--r--
replace "flex item" with "flexbox item"
     1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     5 	<title>CSS Flexible Box Layout Module</title>
     6 	<link rel="stylesheet" type="text/css" href="http://dev.w3.org/csswg/default.css">
     7 	<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-ED">
     8 	<style>
     9 	code.one-line { white-space: pre; }
    10 	.code-and-figure {
    11 		display: table;
    12 		margin: 0 auto;
    13 		border-spacing: 1em;
    14 	}
    15 	.code-and-figure > div {
    16 		display: table-cell;
    17 		vertical-align: middle;
    18 	}
    19 	</style>
    20 </head><body>
    22 <div class="head">
    23 	<!--logo-->
    25 	<h1 id="head-box-flexible">CSS Flexible Box Layout Module</h1>
    26 	<h2 class="no-num no-toc" id="w3c-working">[LONGSTATUS], [DATE]</h2>
    28 	<dl>
    29 		<dt>This version:
    30 		<!--<dd><a href="[VERSION]">[VERSION]</a>-->
    31 		<dd><a href="http://dev.w3.org/csswg/[SHORTNAME]/">http://dev.w3.org/csswg/[SHORTNAME]/</a>
    33 		<dt>Latest version:
    34 		<!--<dd><a href="[LATEST]">[LATEST]</a>-->
    35 		<dd><a href="http://www.w3.org/TR/css3-flexbox/">http://www.w3.org/TR/css3-flexbox/</a>
    37 		<dt>Editor's Draft:
    38 		<dd><a href="http://dev.w3.org/csswg/css3-flexbox/">http://dev.w3.org/csswg/css3-flexbox/</a>
    40 		<dt>Previous versions:
    41 		<dd><a href="http://www.w3.org/TR/2011/WD-css3-flexbox-20111129/">http://www.w3.org/TR/2011/WD-css3-flexbox-20111129/</a>
    42 		<dd><a href="http://www.w3.org/TR/2011/WD-css3-flexbox-20110322/">http://www.w3.org/TR/2011/WD-css3-flexbox-20110322/</a>
    43 		<dd><a href="http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/">http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/</a>
    45 		<dt>Issues List:</dt>
    46         <dd><a href="https://www.w3.org/Bugs/Public/buglist.cgi?product=CSS&component=Flexbox&resolution=---">Bugzilla Bugs for Flexbox</a></dd>
    48 		<dt>Discussion:</dt>
    49 		<dd><a href="http://lists.w3.org/Archives/Public/www-style/">www-style@w3.org</a> with subject line "<code>[css3-flexbox] …message topic…</code>"
    51 		<dt>Editors:
    52 		<dd><a href="http://www.xanthir.com/contact">Tab Atkins Jr.</a>, Google Inc.</dd>
    53 		<dd>Alex Mogilevsky, Microsoft Corporation, <a href="mailto:alexmog@microsoft.com">alexmog@microsoft.com</a>
    54 		<dd>L. David Baron, Mozilla Corporation, <a href="mailto:dbaron@dbaron.org">dbaron@dbaron.org</a>
    56 		<dt>Authors and former editors:
    57 		<dd>Neil Deakin, Mozilla Corporation, <a href="mailto:enndeakin@gmail.com">enndeakin@gmail.com</a>
    58 		<dd>Ian Hickson, formerly of Opera Software, <a href="mailto:ian@hixie.ch">ian@hixie.ch</a>
    59 		<dd>David Hyatt, formerly of Netscape Corporation, <a href="mailto:hyatt@apple.com">hyatt@apple.com</a>
    60 	</dl>
    61 	<!--copyright-->
    63 	<hr title="Separator for header">
    64 </div>
    66 <h2 class="no-num no-toc" id="abstract">
    67 Abstract</h2>
    69 	<p>The specification describes a CSS box model optimized for user interface design. In the flexbox layout model, the children of a flexbox can be laid out in any direction, and can "flex" their sizes, either growing to fill unused space or shrinking to avoid overflowing the parent.  Both horizontal and vertical alignment of the children can be easily manipulated. Nesting of these boxes (horizontal inside vertical, or vertical inside horizontal) can be used to build layouts in two dimensions.</p>
    71 <h2 class="no-num no-toc" id="status">Status of this document</h2>
    72 <!--status-->
    74 <h2 class="no-num no-toc" id="table">Table of contents</h2>
    75 <!--toc-->
    78 <h2 id="intro">
    79 Introduction</h2>
    81 	<p><em>This section is not normative.</em>
    83 	<p>CSS 2.1 defined four layout modes &mdash; algorithms which determine the size and position of boxes based on their relationships with their sibling and ancestor boxes: block layout, designed for laying out documents; inline layout, designed for laying out text; table layout, designed for laying out information in a tabular format; and positioned layout, designed for very explicit positioning without much regard for other elements in the document. This module introduces a new layout mode, flexbox layout, which is designed for laying out more complex applications and webpages.</p>
    85 	<p>Flexbox layout is superficially similar to block layout.  It lacks many of the more complex text or document-formatting properties that can be used in block layout, such as 'float' and 'columns', but in return it gains more simple and powerful tools for aligning its contents in ways that webapps and complex web pages often need.  </p>
    87     <p>The contents of a flexbox can be laid out in any direction (left, right, down, or even up!), can have their order swapped around dynamically (i.e., display order is independent of source order), and can "flex" their sizes and positions to respond to the available space.  If a flexbox is <i>multi-line</i>, the flexbox items flow in two dimensions, wrapping into separate lines in a fashion similar to how text is wrapped into multiple lines.</p>
    89 	<div class="example">
    90 		<p>For example, the following HTML snippet uses flexbox to create a toolbar with icons.  The flexbox is horizontal, and the children's widths don't fill the flexbox's width, so the additional space is distributed around and between the children.  As the flexbox grows (perhaps because the user is viewing the page on a wider screen), the children spread out evenly and automatically:</p>
    92 		<pre>
    93 &lt;ul>
    94   &lt;li>&lt;button>&lt;img src='new.svg' alt="New">&lt;/button>&lt;/li>
    95   &lt;li>&lt;button>&lt;img src='upload.svg' alt="Upload">&lt;/button>&lt;/li>
    96   &lt;li>&lt;button>&lt;img src='save.svg' alt="Save">&lt;/button>&lt;/li>
    97   &lt;li>&lt;button>&lt;img src='trash.svg' alt="trash">&lt;/button>&lt;/li>
    98 &lt;/ul>
    99 &lt;style>
   100 ul { display: flexbox; flex-pack: distribute; }
   101 /* Irrelevant styling for this example removed. */
   102 &lt;/style></pre>
   104 		<div class='figure'>
   105 			<img src="images/toolbar-example.svg" width=400 height=140>
   106 			<p class='caption'>Example rendering of the above code snippet, at two different flexbox widths.</p>
   107 		</div>
   108 	</div>
   110 <h3 id="placement">
   111 Module interactions</h3>
   113 	<p>This module extends the definition of the 'display' property.
   115 <h3 id="values">
   116 Values</h3>
   118 	<p>This specification follows the <a href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property definition conventions</a> from [[!CSS21]]. Value types not defined in this specification are defined in CSS Level 2 Revision 1 [[!CSS21]]. Other CSS modules may expand the definitions of these value types: for example [[CSS3COLOR]], when combined with this module, expands the definition of the &lt;color&gt; value type as used in this specification.</p>
   120 	<p>In addition to the property-specific values listed in their definitions, all properties defined in this specification also accept the <a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">''inherit''</a> keyword as their property value. For readability it has not been repeated explicitly.
   122 <h2 id='box-model'>
   123 The Flexbox Box Model</h2>
   125 	<p>An element with ''display:flexbox'' or ''display:inline-flexbox'' is a <dfn>flexbox</dfn>.  Children of a flexbox are called <dfn title="flexbox item|flexbox items|flexbox item's" id="flexbox-item">flexbox items</dfn> and are laid out using the flexbox box model.</p>
   127 	<p>Unlike block layout, which is normally biased towards laying things out vertically, and inline layout, which is normally biased toward laying things out horizontally, the flexbox layout algorithm is agnostic as to the direction the flexbox happens to be laid out in.  To make it easier to talk about flexbox layout in a general way, we will define several direction-agnostic terms here to make the rest of the spec easier to read and understand.</p>
   129 	<div class='figure'>
   130 		<img src='images/flex-direction-terms.svg' width=510 height=300>
   131 		<p class='caption'>An illustration of the various directions and sizing terms used in this specification, respectively for ''row'' and ''column'' flexboxes.</p>
   132 	</div>
   134 	<p>The <dfn>main axis</dfn> of a flexbox is the axis on which <i>flexbox items</i> are laid out along.  The <i>flexbox items</i> are ordered such that they start on the <dfn>main-start</dfn> side of the flexbox, and go toward the <dfn>main-end</dfn> side.  A <i>flexbox item's</i> width or height, whichever is in the <i>main axis</i>, is the item's <dfn>main size</dfn>.  The <i>flexbox item's</i> <dfn>main size property</dfn> is either the 'width' or 'height' property, whichever is in the <i>main axis</i>.</p>
   136 	<p>The axis perpendicular to the <i>main axis</i> is called the <dfn>cross axis</dfn>, and similarly has <dfn>cross-start</dfn> and <dfn>cross-end</dfn> directions and sides defined.  The width or height of a <i>flexbox item</i>, whichever is in the <i>cross axis</i>, is the item's <dfn>cross size</dfn>, and similarly the <dfn>cross size property</dfn> is whichever of 'width' or 'height' that is in the <i>cross axis</i>.</p>
   138 	<p>The contents of a flexbox can be easily and powerfully manipulated with a handful of properties.  Most significantly, <i>flexbox items</i> can "flex" their <i>main size</i> by using the 'flex' property.  This "flexing" allows the items to get bigger or smaller based on the available space in the page.  If there is leftover space in the flexbox after all of the <i>flexbox items</i> have finished flexing, the items can be aligned, centered, or distributed with the 'flex-pack' property.  <i>Flexbox items</i> can also be completely rearranged within the flexbox with the 'flex-order' property.</p>
   140 	<p>In the <i>cross axis</i>, <i>flexbox items</i> can either "flex" to fill the available space or be aligned within the space with the 'flex-align' property.  If a flexbox is <i>multi-line</i>, new lines are added in the <i>cross-end</i> direction, and can similarly be aligned, centered, or distributed within the flexbox with the 'flex-line-pack' property.</p>
   143 <h2 id='display-flexbox'>
   144 New values for 'display' property</h2>
   146 	<table class="propdef">
   147 		<tr>
   148 			<th>Name:
   149 			<td>display
   150 		<tr>
   151 			<th><a href="http://dev.w3.org/csswg/css-module/#values">New value</a>:
   152 			<td>flexbox | inline-flexbox
   153 	</table>
   155 	<p>You can declare that an element is a flexbox, and thus should use flexbox layout for its contents, by setting the 'display' property on the element to the value 'flexbox' or 'inline-flexbox'.</p>
   157 	<p>The ''flexbox'' value makes the flexbox a block-level element.  The ''inline-flexbox'' value makes the flexbox an inline-level element.  When it is necessary to distinguish them, this specification will refer to the former kind of flexbox as a <dfn id="block-flexbox" title="block flexbox|block flexboxes">block flexbox</dfn> and the latter type as an <dfn id="inline-flexbox" title="inline flexbox|inline flexboxes">inline flexbox</dfn>.</p>
   159 	<p>Flexboxes use a new layout algorithm, and so some properties that were designed with the assumption of block layout don't make sense in a flexbox context.  In particular:</p>
   161 	<ul>
   162 		<li>all of the 'column-*' properties in the Multicol module have no effect on a flexbox.</li>
   164 		<li>'float' and 'clear' have no effect on a flexbox item.  Using 'float' on an element still causes that element's 'display' property to compute to ''block'', as normal, because that occurs before flexbox items are determined (the algorithm for wrapping children of a flexbox into <i>flexbox items</i> needs the computed value of 'display').</li>
   166 		<li>'vertical-align' has no effect on the alignment of a flexbox item in the flexbox</li>
   167 	</ul>
   169 	<p>If an element's specified value for 'display' is ''inline-flexbox'' and the element is floated or absolutely positioned, the computed value of 'display' must be ''flexbox''.</p>
   171 	<p>A flexbox establishes a new <dfn>flexbox formatting context</dfn> for its contents.  This is similar to a block formatting context root: floats do not intrude into the flexbox, and the flexbox's margins do not collapse with the margins of its contents.  Additionally, each of the <i>flexbox items</i> establish a new formatting context for its contents.</p>
   173 <h2 id='flex-items'>
   174 Flexbox Items</h2>
   176 	<p>Flexbox layout algorithm operates on <i>flexbox items</i>, which are boxes that satisfy at least one of the following criteria:</p>
   178 	<ol>
   179 		<li>Immediate block-level children of flexbox</li>
   181 		<li>Atomic inline-level children of flexbox</li>
   183 		<li>Contiguous run of non-replaced inline children, wrapped into an anonymous box</li>
   184 	</ol>
   186 	<p>Some values of 'display' trigger "fixup" to ensure a sensible tree structure.  For example, a lone ''table-cell'' box is fixed up by generating ''table'', ''table-row-group'', and ''table-row'' boxes around it.  This fixup must occur <em>before</em> a flexbox's contents are checked to see if it's necessary to generate anonymous flexbox items.</p>
   188 	<p class='note'>In the future, other kinds of fixup such as ''display:run-in'' or ''display:ruby'' should also run before flexbox fixup.</p>
   190 	<div class="example">
   191 		<p>Examples of flexbox items:</p>
   192 		<pre>
   193 &lt;div style="display:flexbox">
   195     &lt;!-- flexbox item: block-level child -->
   196     &lt;div id="item1">block&lt;/div>
   198     &lt;!-- not a flexbox item, because it's out-of-flow -->
   199     &lt;div id="not-an-item1.5" style="position: absolute;">block&lt;/div>
   201     &lt;!-- flexbox item: block-level child -->
   202     &lt;div id="item2" style="display:table">table&lt;/div>
   204     &lt;!-- flexbox item: anonymous table wrapped around table-cell -->
   205     &lt;div id="item3" style="display:table-cell">table-cell&lt;/div> 
   207     &lt;!-- flexbox item: anonymous block around inline content -->
   208     anonymous item 4
   210     &lt;!-- flexbox item: block-level child -->
   211     &lt;div id="item5">block&lt;/div>
   213     &lt;!-- flexbox item: anonymous block around inline content -->
   214     anonymous item 6.1
   215     &lt;span id="item6.1">
   216         text 6.2
   217         &lt;div id="not-an-item6.3">block&lt;/div>
   218         text 6.4
   219     &lt;/span>
   221     &lt;!-- flexbox item: block-level replaced element -->
   222     &lt;iframe id="item7"></iframe>
   224     &lt;!-- flexbox item: inline-level replaced element -->
   225     &lt;img id="item7" style="display:inline">
   227     &lt;!-- flexbox item: inline-level replaced element -->
   228     &lt;button id="item8">button&lt;/button>
   230     &lt;!-- flexbox item: inline-table -->
   231     &lt;div id="item9" style="display:inline-table">table&lt;/div>
   233     &lt;!-- flexbox item: floated inline, which changes to a block -->
   234     &lt;span id="item10" style="float: left;">span&lt;/span>
   235 &lt;/div></pre>
   237 		<p>Notice that block element "not-an-item6.3" is not a separate flexbox item, because it is contained inside an inline element which is being wrapped into an anonymous 
   238 		flexbox item.  Similarly, the block element "not-an-item1.5" is not a flexbox item, because it's absolutely positioned and thus out of flow.</p>
   239 	</div>
   241 <h3 id='abspos-flexbox-items'>
   242 Absolutely Positioned Flexbox Children</h3>
   244 	<p>Absolutely positioned children of a flexbox are not <i>flexbox items</i>, but they leave behind "placeholders" in their normal position in the box tree.  These placeholders are anonymous inline boxes with a width and height of ''0px'', and they interact normally with the flexbox layout algorithm.  In particular, they'll trigger the creation an anonymous flexbox item wrapper boxes, or join neighboring inline elements in <em>their</em> anonymous flexbox item wrapper boxes.</p>
   246 	<p>The "static position" of an absolutely positioned child of a flexbox (the position when the 'top'/'right'/'bottom'/'left' properties are ''auto''), then, is the final position of their corresponding placeholder, after flexbox layout has been performed.</p>
   248 	<p class='note'>Note: In most cases, this means that absolutely positioned items will have no effect on flexbox layout, even if they force the generation of an anonymous flexbox item wrapper, because those wrapper items will also collapse to zero size and have no effect.  The only exception is when the flexbox has ''flex-pack:justify'', in which case the anonymous flexbox item will cause there to be two packing spaces where there would otherwise be only one, which will appear as a double-size space between two "real" items.</p>
   251 <h2 id='multi-line'>
   252 Multi-line Flexbox</h2>
   254 	<p>A flexbox can be either <i>single-line</i> or <i>multi-line</i>, depending on the 'flex-wrap' property.  A <dfn>single-line</dfn> flexbox lays out all of its children in a single line, even if that would cause the flexbox to overflow its bounds.  A <dfn>multi-line</dfn> flexbox breaks its <i>flexbox items</i> across multiple lines to avoid overflowing, similar to how text is broken onto a new line when it gets too wide to fit on the existing line.  Every line contains at least one <i>flexbox item</i>, unless the flexbox itself is completely empty.</p>
   256 	<p>When additional lines are created, they are stacked in the flexbox in the <i>cross axis</i>.  Each line is completely independent; flexible lengths and the 'flex-pack' and 'flex-align' properties only consider the items on a single line at a time.  The <i>main size</i> of a line is the same as the <i>main size</i> of the flexbox's content box.  The <i>cross size</i> of a line depends on whether the flexbox is <i>single-line</i> or <i>multi-line</i>: the <i>cross size</i> of the sole line in a <i>single-line</i> flexbox is the same as the <i>cross size</i> of the flexbox's content box, while the <i>cross size</i> of a line in a <i>multi-line</i> flexbox is the minimum size necessary to contain the <i>flexbox items</i> on the line, after aligning them with 'flex-align'.  The lines themselves are then aligned within a flexbox with the 'flex-line-pack' property.</p>
   258 	<div class=example>
   259 		<p>This example shows four buttons that do not fit horizontally.</p>
   261 		<pre>&lt;style>
   262 #div1 {
   263 	display: flexbox;
   264 	flex-flow: row wrap;
   265 	width: 300px;
   266 }
   267 button {
   268 	flex:80px 1;
   269 }
   270 &lt;style>
   272 &lt;div id="div1">
   273 	&lt;button id="button1">Elephant&lt;/button>
   274 	&lt;button id="button2">Tiger&lt;/button>
   275 	&lt;button id="button3">Antelope&lt;/button>
   276 	&lt;button id="button4">Wildebeest&lt;/button>
   277 &lt;/div></pre>
   279 		<p>The buttons are first set to their preferred widths, in this case 80 pixels. This will allow the first three buttons to fit in 240 pixels with 60 pixels left over of remaining space. Because the 'flex-flow' property specifies a multi-line flexbox (due to the ''wrap'' keyword appearing in its value), the flexbox will create an additional line to contain the last button.</p>
   281 		<p>Flexibility is applied to each element, separately for each line. The first line has 60 pixels of remaining space and all of the buttons have the same flexibility, so each of the three buttons on that line will receive 20 pixels of extra width, ending up 100px wide. The remaining button is on a line of its own and will stretch to the entire width of the line, or 300 pixels.</p>
   283 		<div style="width:300px; border:medium solid green; overflow: hidden;">
   284 			<button style="width:100px; float: left;">Elephant</button>
   285 			<button style="width:100px; float: left;">Tiger</button>
   286 			<button style="width:100px; float: left;">Antelope</button>
   287 			<button style="width:300px; float: left;">Wildebeest</button>
   288 		</div>
   290 		<p>If the box was resized, the buttons may rearrange onto different lines as necessary.</p>
   292 		<p>If the style rules in the example above were changed to the following:</p>
   294 		<pre>
   295 #div1 {
   296 	display: flexbox;
   297 	flex-flow: row wrap;
   298 	flex-pack: center;
   299 	width: 300px;
   300 }
   301 button {
   302 	flex:80px 1;
   303 	max-width: 90px;
   304 }</pre>
   306 		<p>Similar to the previous example, the first three buttons will fit on the first line, and the last button will wrap onto a new line.  However, when the buttons attempt to flex they can only grow to 90px each, due to their 'max-width' property.  This leaves 30px of free space on the first line and 210px of free space on the second line.  Because 'flex-pack' is set to ''center'', the buttons will be centered on each line, with the free space split equally on either side.</p>
   308 		<div style="width:300px; border:medium solid green; text-align:center;">
   309 			<button style="width:90px; float: left; margin-left: 15px;">Elephant</button>
   310 			<button style="width:90px; float: left;">Tiger</button>
   311 			<button style="width:90px; float: left;">Antelope</button>
   312 			<button style="width:90px">Wildebeest</button>
   313 		</div>
   314 	</div>
   316 <h2>
   317 Ordering and Orientation</h2>
   319 	<p>The first level of flexbox functionality is the ability to lay out a flexbox's contents in any direction and in any order.  This allows an author to trivially achieve effects that would previously have required complex or fragile methods, such as using the 'float' property to lay out a horizontal navigation bar (which then requires further effort with the 'clear' property or others to make the elements interact nicely with the rest of the page).  This functionality is exposed through the 'flex-flow' and 'flex-order' properties.</p>
   321 <h3 id='flex-direction'>
   322 Flexbox Flow Direction: the 'flex-direction' property</h3>
   324 	<table class=propdef>
   325 		<tr>
   326 			<th>Name:</th>
   327 			<td><dfn>flex-direction</dfn>
   328 		<tr>
   329 			<th><a href="http://dev.w3.org/csswg/css-module/#values">Value</a>:
   330 			<td>row | row-reverse | column | column-reverse
   331 		<tr>
   332 			<th>Initial:
   333 			<td>row
   334 		<tr>
   335 			<th>Applies To:
   336 			<td>flexboxes
   337 		<tr>
   338 			<th>Inherited:
   339 			<td>no
   340 		<tr>
   341 			<th>Computed Value:
   342 			<td>specified value
   343 		<tr>
   344 			<th>Media:
   345 			<td>visual
   346 		<tr>
   347 			<th>Animatable:
   348 			<td>no
   349 	</table>
   351 	<p>The 'flex-direction' property specifies how <i>flexbox items</i> are placed in the flexbox, by setting the direction of the flexbox's <i>main axis</i>.  This affects the direction that flexbox items are laid out in, and the meaning of the 'flex-pack' property.</p>
   353 	<dl>
   354 		<dt><dfn id='flex-flow-row'>row</dfn></dt>
   355 		<dd>The flexbox's <i>main axis</i> has the same orientation as the inline axis of the current writing mode (the direction that text is laid out in).  The <i>main-start</i> and <i>main-end</i> directions are equivalent to the "start" and "end" directions, respectively, of the current writing mode.</dd>
   357 		<dt><dfn id='flex-flow-row-reverse'>row-reverse</dfn></dt>
   358 		<dd>Same as <i>row</i>, except the <i>main-start</i> and <i>main-end</i> directions are swapped.</dd>
   360 		<dt><dfn id='flex-flow-column'>column</dfn></dt>
   361 		<dd>The flexbox's <i>main axis</i> has the same orientation as the block axis of the current writing mode (the direction that blocks are laid out in).  The <i>main-start</i> and <i>main-end</i> directions are equivalent to the "before" and "after" directions, respectively, of the current writing mode.</dd>
   363 		<dt><dfn id='flex-flow-column-reverse'>column-reverse</dfn></dt>
   364 		<dd>Same as <i>column</i>, except the <i>main-start</i> and <i>main-end</i> directions are swapped.</dd>
   365 	</dl>
   367 <h3 id='flex-wrap'>
   368 Flexbox Wrapping: the 'flex-wrap' property</h3>
   370 	<table class=propdef>
   371 		<tr>
   372 			<th>Name:</th>
   373 			<td><dfn>flex-wrap</dfn>
   374 		<tr>
   375 			<th><a href="http://dev.w3.org/csswg/css-module/#values">Value</a>:
   376 			<td>nowrap | wrap | wrap-reverse
   377 		<tr>
   378 			<th>Initial:
   379 			<td>nowrap
   380 		<tr>
   381 			<th>Applies To:
   382 			<td>flexboxes
   383 		<tr>
   384 			<th>Inherited:
   385 			<td>no
   386 		<tr>
   387 			<th>Computed Value:
   388 			<td>specified value
   389 		<tr>
   390 			<th>Media:
   391 			<td>visual
   392 		<tr>
   393 			<th>Animatable:
   394 			<td>no
   395 	</table>
   397 	<p>The 'flex-wrap' property controls whether the flexbox is <i>single-line</i> or <i>multi-line</i>, and the direction of the <i>cross axis</i>, which affects the direction new lines are stacked in and the meaning of the 'flex-align', 'flex-item-align', and 'flex-line-pack' properties.</p>
   399 	<dl>
   400 		<dt>nowrap</dt>
   401 		<dd>The flexbox is <i>single-line</i>.  The <i>cross-start</i> direction is equivalent to either the "start" or "before" direction of the current writing mode, whichever is in the <i>cross-axis</i>, and the <i>cross-end</i> direction is the opposite direction of <i>cross-start</i>.
   402 			</dd>
   404 		<dt><dfn id='flex-flow-wrap'>wrap</dfn></dt>
   405 		<dd>The flexbox is <i>multi-line</i>.  The <i>cross-start</i> direction is equivalent to either the "start" or "before" direction of the current writing mode, whichever is in the <i>cross-axis</i>, and the <i>cross-end</i> direction is the opposite direction of <i>cross-start</i>.</dd>
   407 		<dt><dfn id='flex-flow-wrap-reverse'>wrap-reverse</dfn></dt>
   408 		<dd>Same as <i>wrap</i>, except the <i>cross-start</i> and <i>cross-end</i> directions are swapped.</dd>
   409 	</dl>
   411 <h3 id='flex-flow'>
   412 Flex Direction and Wrap: the 'flex-flow' shorthand</h3>
   414 	<table class=propdef>
   415 		<tr>
   416 			<th>Name:</th>
   417 			<td><dfn>flex-flow</dfn>
   418 		<tr>
   419 			<th><a href="http://dev.w3.org/csswg/css-module/#values">Value</a>:
   420 			<td>&lt;&apos;flex-direction&apos;> || &lt;&apos;flex-wrap&apos;>
   421 		<tr>
   422 			<th>Initial:
   423 			<td>see individual properties
   424 		<tr>
   425 			<th>Applies To:
   426 			<td>flexboxes
   427 		<tr>
   428 			<th>Inherited:
   429 			<td>see individual properties
   430 		<tr>
   431 			<th>Computed Value:
   432 			<td>see individual properties
   433 		<tr>
   434 			<th>Media:
   435 			<td>visual
   436 		<tr>
   437 			<th>Animatable:
   438 			<td>no
   439 	</table>
   441 	<p>The 'flex-flow' property is a shorthand for setting the 'flex-direction' and 'flex-wrap' properties together.</p>
   443 	<div class="example">
   444 		<p>Some examples of valid flows:</p>
   446 		<table style="margin: 0 auto; vertical-align: middle; border-spacing: 2em 1em;">
   447 			<tr>
   448 				<td><pre>
   449 div { flex-flow: row; }
   450 /* Initial value. Main axis is 
   451    inline, no wrap. */</pre>
   452 				<td><img src='images/flex-flow1.svg' width=240 height=80>
   453 			<tr>
   454 				<td><pre>
   455 div { flex-flow: column wrap; }
   456 /* Main axis is block-direction and lines
   457    wrap in the inline direction.  For an 
   458    English page, the main axis is top-to-bottom
   459    and lines wrap to the right. */</pre>
   460 				<td><img src='images/flex-flow2.svg' width=170 height=200>
   461 			<tr>
   462 				<td><pre>
   463 div { writing-mode: vertical-rl;
   464       flex-flow: column wrap-reverse; }
   465 /* Main axis is block direction (right to 
   466    left). New lines wrap upwards. */</pre>
   467 				<td><img src='images/flex-flow3.svg' width=200 height=170>
   468 		</table>
   469 	</div>
   472 <h3 id='flex-order'>
   473 Display Order: the 'flex-order' property</h3>
   475 	<p><i>Flexbox items</i> are, by default, displayed and laid out in the same order as they appear in the source document.  The 'flex-order' property may be used to change this ordering.</p>
   477 	<table class=propdef>
   478 		<tr>
   479 			<th>Name:
   480 			<td><dfn>flex-order</dfn>
   481 		<tr>
   482 			<th><a href="http://dev.w3.org/csswg/css-module/#values">Value</a>:
   483 			<td>&lt;number>
   484 		<tr>
   485 			<th>Initial:
   486 			<td>0
   487 		<tr>
   488 			<th>Applies to:
   489 			<td><i>flexbox items</i></td>
   490 		<tr>
   491 			<th>Inherited:
   492 			<td>no
   493 		<tr>
   494 			<th>Computed value:
   495 			<td>specified value
   496 		<tr>
   497 			<th>Media:
   498 			<td>visual
   499 		<tr>
   500 			<th>Animatable:
   501 			<td>yes
   502 	</table>
   504 	<p>The 'flex-order' property assigns <i>flexbox items</i> to ordinal groups.</p>
   506 	<p>Ordinal groups control the order in which <i>flexbox items</i> appear.  A flexbox will lay out its content starting from the lowest numbered ordinal group and going up.  Items with the same ordinal group are laid out in the order they appear in the source document.  'flex-order' has no effect on stacking/layering; elements must still be drawn over/under each other based on document order, 'z-index', and other relevant means.</p>
   508 	<div class='example'>
   509 		<p>The following figure shows a simple tabbed interface, where the tab for the active pane is always in front:</p>
   511 		<div class='figure'><img src="images/flex-order-example.png"></div>
   513 		<p>This could be implemented with the following CSS (showing only the flexbox-relevant code):</p>
   515 		<pre>
   516 .tabs {
   517 	display: flexbox;
   518 }
   519 .tabs > .current {
   520 	flex-order: -1; /* Lower than the default of 0 */
   521 }</pre>
   523 	</div>
   525 	<div class='example'>
   526 		<p>Many web pages have a similar shape in the markup, with a header on top, a footer on bottom, and then a content area and one or two additional columns in the middle.  Generally, it's desirable that the content come first in the page's source code, before the additional columns.  However, this makes many common designs, such as simply having the additional columns on the left and the content area on the right, difficult to achieve.  This has been addressed in many ways over the years, often going by the name "Holy Grail Layout" when there are two additional columns.  'flex-order' makes this trivial.  For example, take the following sketch of a page's code and desired layout:</p>
   528 		<div class='code-and-figure'>
   529 			<div><pre>
   530 &lt;!DOCTYPE html>
   531 &lt;header>...&lt;/header>
   532 &lt;div id='main'>
   533    &lt;article>...&lt;/article>
   534    &lt;nav>...&lt;/nav>
   535    &lt;aside>...&lt;/aside>
   536 &lt;/div>
   537 &lt;footer>...&lt;/footer></pre></div>
   538 			<div><img src="images/flex-order-page.svg" width=400 height=360></div>
   539 		</div>
   541 		<p>This layout can be easily achieved with Flexbox:</p>
   543 		<pre>
   544 #main { display: flexbox; }
   545 #main > article { flex:1;         flex-order: 2; }
   546 #main > nav     { width: 200px;   flex-order: 1; }
   547 #main > aside   { width: 200px;   flex-order: 3; }</pre>
   549 		<p>As an added bonus, the columns will all be equal-height by default, and the main content will be as wide as necessary to fill the screen.  Additionally, this can then be combined with media queries to switch to an all-vertical layout on narrow screens:</p>
   551 		<pre>
   552 @media all and (max-width: 600px) {
   553 	/* Too narrow to support three columns */
   554 	#main { flex-flow: column; }
   555 	#main > article, #main > nav, #main > aside {
   556 		/* Return them to document order */
   557 		flex-order: 0; width: auto;
   558 	}
   559 }</pre>
   561 		<p><small>(Further use of multiline flexboxes to achieve even more intelligent wrapping left as an exercise for the reader.)</small></p>
   562 	</div>
   565 <h2 id='flexibility'>
   566 Flexibility: the 'flex' property</h2>
   568 	<p>The defining aspect of flexbox layout is the ability to make the <i>flexbox items</i> "flex", altering their width or height to fill the available space. This is done by using a 'flex' property. A flexbox distributes free space to its items proportional to their positive flexibility, or shrinks them to prevent overflow proportional to their negative flexibility.</p>
   570 	<table class=propdef>
   571 		<tr>
   572 			<th>Name:
   573 			<td><dfn>flex</dfn>
   574 		<tr>
   575 			<th><a href="http://dev.w3.org/csswg/css-module/#values">Value</a>:
   576 			<td>[ [ &lt;pos-flex> &lt;neg-flex>? ] || &lt;preferred-size> ] | none 
   577 		<tr>
   578 			<th>Initial:
   579 			<td>none
   580 		<tr>
   581 			<th>Applies to:
   582 			<td>flexbox items
   583 		<tr>
   584 			<th>Inherited:
   585 			<td>no
   586 		<tr>
   587 			<th>Computed Value:
   588 			<td>specified value
   589 		<tr>
   590 			<th>Media:
   591 			<td>visual
   592 		<tr>
   593 			<th>Animatable:
   594 			<td>yes
   595 	</table>
   597 	<p>The 'flex' property specifies the parameters of a <dfn title="flexible length|flexible lengths|flexible length's">flexible length</dfn>: the <dfn id="positive-flexibility" title="positive flexibility">positive</dfn> and <dfn>negative flexibility</dfn>, and the <dfn>preferred size</dfn>.</p>
   599 	<p><code>&lt;pos-flex></code> and <code>&lt;neg-flex></code> are non-negative <code>&lt;number>s</code>. The <code>&lt;pos-flex></code> component sets the <i>positive flexibility</i>; if omitted, the <i>positive flexibility</i> defaults to ''1''. The <code>&lt;neg-flex></code> component sets the <i>negative flexibility</i>; if omitted, it defaults to ''0''.  </p>
   600 <p> The <code>&lt;preferred-size></code> component sets the preferred size. It can be set to any value that would be valid in the 'width' or 'height' property, 
   601 	except values that are not applicable to a component value (of values 
   602 	defined in CSS2.1, only &#39;inherit&#39; is not valid for <code>&lt;preferred-size></code>; in the future other values may be introduced that are not applicable as length component). 
   603 If omitted, the preferred size defaults to ''0px''. If set to 'auto', the value of 'width' or 'height' (whichever is in parallel to main axis) is used as preferred size.</p>
   604 <p> &nbsp;If the <code>&lt;preferred-size></code> is ''0'', it <strong>must</strong> be specified with a unit (like ''0px'') to avoid ambiguity; unitless zero will either be interpreted as as one of the flexibilities, or is a syntax error.</p>
   606 	<p>The keyword 'none' is equivalent to "0 0 auto". </p>
   609 	<p>A ''&lt;flex>'' value is transitionable, by transitioning the <i>preferred size</i>, <i>positive flexibility</i>, and <i>negative flexibility</i> independently.  ''&lt;flex>'' can also transition to and from a &lt;length>, by treating the length as if it were a flexible length with a positive and negative flexibility of zero and a preferred size of the length.</p>
   611 	<div class='example'>
   612 		<p>Flexibility allows elements to respond directly to the available space, 
   613 		optionally taking into account size of content:</p>
   615 		<pre>
   616 &lt;!DOCTYPE html>
   617 &lt;style>
   618 	div { display:flexbox; outline:1px solid silver; }
   619 	p { flex:1 auto; margin:1em; background:gold; }
   620 &lt;/style&gt;
   621 &lt;div&gt;
   622 	&lt;p&gt;&quot;flexing&quot;&lt;/p&gt;
   623 	&lt;p&gt;allows the items to get bigger&lt;/p&gt;
   624 	&lt;p&gt;or&lt;/p&gt;
   625 	&lt;p&gt;smaller&lt;/p&gt;
   626 &lt;/div&gt;
   627 </pre>
   629 <img src="images/wp7zxxyu.gif" alt="items with equal flexibility extend by equal amount">
   631 </div> 
   633 <h2 id='alignment'>
   634 Alignment</h2>
   636 	<p>After a flexbox's contents have finished their flexing and dimensions of 
   637 	margin boxes of all flexbox items are finalized, they can be aligned in both the <i>main axis</i> with 'flex-pack' and the <i>cross axis</i> with 'flex-align' and 'flex-item-align'.  These properties make many common types of alignment trivial, including some things that were very difficult in CSS 2.1, like horizontal and vertical centering.</p>
   640 <h3 id='flex-pack'>
   641 Axis Alignment: the 'flex-pack' property</h3>
   643 	<table class=propdef>
   644 		<tr>
   645 			<th>Name:
   646 			<td><dfn>flex-pack</dfn>
   647 		<tr>
   648 			<th><a href="http://dev.w3.org/csswg/css-module/#values">Value</a>:
   649 			<td>start | end | center | justify | distribute
   650 		<tr>
   651 			<th>Initial:
   652 			<td>start
   653 		<tr>
   654 			<th>Applies to:
   655 			<td>flexboxes
   656 		<tr>
   657 			<th>Inherited:
   658 			<td>no
   659 		<tr>
   660 			<th>Computed Value:
   661 			<td>specified value
   662 		<tr>
   663 			<th>Media:
   664 			<td>visual
   665 		<tr>
   666 			<th>Animatable:
   667 			<td>no
   668 	</table>
   670 	<p>The 'flex-pack' property aligns <i>flexbox items</i> in the <i>main axis</i> of the current line of the flexbox.  This is done <em title=''>after</em> any flexible lengths 
   671 	and any auto margins have been resolved.  Typically it helps distribute extra free space leftover when either all the <i>flexbox items</i> on a line are inflexible, or are flexible but have reach their maximum size, but it also exerts some control over the alignment of items when they overflow the line.</p>
   673 	<dl>
   674 		<dt><dfn id='flex-pack-start'>start</dfn></dt>
   675 		<dd><i>Flexbox items</i> are packed toward the start of the line.  The <i>main-start</i> margin edge of the first <i>flexbox item</i> on the line is placed flush with the <i>main-start</i> edge of the line, and each subsequent <i>flexbox item</i> is placed flush with the preceding item.</dd>
   677 		<dt><dfn id='flex-pack-end'>end</dfn></dt>
   678 		<dd><i>Flexbox items</i> are packed toward the end of the line.  The <i>main-end</i> margin edge of the last <i>flexbox item</i> is placed flush with the <i>main-end</i> edge of the line, and each preceding <i>flexbox item</i> is placed flush with the subsequent item.</dd>
   680 		<dt><dfn id='flex-pack-center'>center</dfn></dt>
   681 		<dd><i>Flexbox items</i> are packed toward the center of the line.  The <i>flexbox items</i> on the line are placed flush with each other and aligned in the center of the line, with equal amounts of empty space between the <i>main-start</i> edge of the line and the first item on the line and between the <i>main-end</i> edge of the line and the last item on the line.  (If the leftover free-space is negative, the <i>flexbox items</i> will overflow equally in both directions.)</dd>
   683 		<dt><dfn id='flex-pack-justify'>justify</dfn></dt>
   684 		<dd><i>Flexbox items</i> are evenly distributed in the line.  If the leftover free-space is negative or there is only a single <i>flexbox item</i> on the line, this value is identical to ''start''.  Otherwise, the <i>main-start</i> margin edge of the first <i>flexbox item</i> on the line is placed flush with the <i>main-start</i> edge of the line, the <i>main-end</i> margin edge of the last <i>flexbox item</i> on the line is placed flush with the <i>main-end</i> edge of the line, and the remaining <i>flexbox items</i> on the line are distributed so that the empty space between any two adjacent items is the same.</dd>
   686 		<dt><dfn id='flex-pack-distribute'>distribute</dfn></dt>
   687 		<dd><i>Flexbox items</i> are evenly distributed in the line, with half-size spaces on either end.  If the leftover free-space is negative or there is only a single <i>flexbox item</i> on the line, this value is identical to ''center''.  Otherwise, the <i>flexbox items</i> on the line are distributed such that the empty space between any two adjacent <i>flexbox items</i> on the line is the same, and the empty space before the first and after the last <i>flexbox items</i> on the line are half the size of the other empty spaces.</dd>
   688 	</dl>
   690 	<div class="figure">
   691 		<img src="images/flex-pack.svg" width=504 height=270>
   692 		<p class='caption'>An illustration of the five 'flex-pack' keywords and their effects on a flexbox with three colored items.</p>
   693 	</div>
   696 <h3 id='flex-align'>
   697 Cross Axis Alignment: the 'flex-align' and 'flex-item-align' properties</h3>
   699 	<table class=propdef>
   700 		<tr>
   701 			<th>Name:
   702 			<td><dfn>flex-align</dfn>
   703 		<tr>
   704 			<th><a href="http://dev.w3.org/csswg/css-module/#values">Value</a>:
   705 			<td>start | end | center | baseline | stretch
   706 		<tr>
   707 			<th>Initial:
   708 			<td>stretch
   709 		<tr>
   710 			<th>Applies to:
   711 			<td>flexboxes
   712 		<tr>
   713 			<th>Inherited:
   714 			<td>no
   715 		<tr>
   716 			<th>Computed Value:
   717 			<td>specified value
   718 		<tr>
   719 			<th>Media:
   720 			<td>visual
   721 		<tr>
   722 			<th>Animatable:
   723 			<td>no
   724 	</table>
   726 	<table class=propdef>
   727 		<tr>
   728 			<th>Name:
   729 			<td><dfn>flex-item-align</dfn>
   730 		<tr>
   731 			<th><a href="http://dev.w3.org/csswg/css-module/#values">Value</a>:
   732 			<td>auto | start | end | center | baseline | stretch
   733 		<tr>
   734 			<th>Initial:
   735 			<td>auto
   736 		<tr>
   737 			<th>Applies to:
   738 			<td><i>flexbox items</i>
   739 		<tr>
   740 			<th>Inherited:
   741 			<td>no
   742 		<tr>
   743 			<th>Computed Value:
   744 			<td>''auto'' computes to parent's 'flex-align'; otherwise as specified
   745 		<tr>
   746 			<th>Media:
   747 			<td>visual
   748 		<tr>
   749 			<th>Animatable:
   750 			<td>no
   751 	</table>
   753 	<p><i>Flexbox items</i> can be aligned in the <i>cross axis</i> of the current line of the flexbox, similar to 'flex-pack' but in the perpendicular direction.  'flex-align' sets the default alignment for all of the flexbox's <i title="flexbox items">items</i>, including anonymous <i>flexbox items</i>.  'flex-item-align' allows this default alignment to be overridden for individual <i>flexbox items</i> (for anonymous flexbox items, 'flex-item-align' always matches the value of 'flex-align' on their associated flexbox).</p>
   755 	<p>A value of <dfn id="flex-item-align-auto">''auto''</dfn> for 'flex-item-align' computes to the value of 'flex-align' on the <i>flexbox item's</i> flexbox.  The alignments are defined as:</p>
   757 	<dl>
   758 		<dt><dfn id="flex-align-start">start</dfn></dt>
   759 		<dd>The <i>cross-start</i> margin edge of the <i>flexbox item</i> is placed flush with the <i>cross-start</i> edge of the line.</dd>
   761 		<dt><dfn id="flex-align-end">end</dfn></dt>
   762 		<dd>The <i>cross-end</i> margin edge of the <i>flexbox item</i> is placed flush with the <i>cross-end</i> edge of the line.</dd>
   764 		<dt><dfn id="flex-align-center">center</dfn></dt>
   765 		<dd>The <i>flexbox item's</i> margin box is centered in the <i>cross axis</i> within the line.  (If the <i>cross size</i> of the flexbox is less than that of the <i>flexbox item</i>, it will overflow equally in both directions.)</dd>
   767 		<dt><dfn id="flex-align-baseline">baseline</dfn></dt>
   768 		<dd>
   769 			<p>If the <i>flexbox item's</i> inline axis is the same as the <i>cross axis</i>, this value is identical to ''start''.</p>
   771 			<p>Otherwise, all <i>flexbox items</i> on the line with an alignment of ''baseline'' that don't run afoul of the previous paragraph are aligned such that their baselines align, and the item with the largest distance between its baseline and its <i>cross-start</i> margin edge is placed flush against the <i>cross-start</i> edge of the line.</p>
   772 		</dd>
   774 		<dt><dfn id="flex-align-stretch">stretch</dfn></dt>
   775 		<dd>
   776 			<p>If the <i>cross size property</i> of the <i>flexbox item</i> is ''auto'', it resolves to the length necessary to make the <i>cross size</i> of the item's margin box the same size as the line, while still respecting 'min/max-width/height' constraints as normal.</p>
   778 			<p>The <i>cross-start</i> margin edge of the <i>flexbox item</i> is placed flush with the <i>cross-start</i> edge of the line.</p>
   779 		</dd>
   780 	</dl>
   782 	<div class='figure'>
   783 		<img src="images/flex-align.svg" width=508 height=377>
   784 		<p class='caption'>An illustration of the five 'flex-align' keywords and their effects on a flexbox with four colored items.</p>
   785 	</div>
   787 	<div class=example>   
   788 		<p>By using a vertical flexbox and 'flex-align', we can achieve behavior very close to HTML's <code>&lt;center></code> element:</p>
   790 		<div class='code-and-figure'>
   791 			<div><pre>
   792 &lt;div>
   793   &lt;p>foo foo foo foo&lt;/p>
   794   &lt;p>bar bar&lt;br>bar bar&lt;/p>
   795   &lt;p>foo foo foo foo foo foo foo
   796      foo foo foo foo foo&lt;/p>
   797 &lt;/div>
   798 &lt;style>
   799   div {
   800     display: flexbox;
   801     flex-flow: column;
   802     flex-align: center;
   803     width: 200px;
   804   }
   805 &lt;/style></pre></div>
   806 			<div><p><img alt="" src="images/basic-vertical-flexbox.png"></p></div>
   807 		</div>
   808 	</div>
   811 <h3 id='auto-margins'>
   812 Resolving &#39;auto&#39; margins</h3>
   813 <p>
   814 Margins on flexbox items can be set to &#39;auto&#39;, with effect very similar to auto 
   815 margins in normal flow. </p>
   816 <ul>
   817 	<li>Through calculations of preferred sizes and flexible lengths, auto 
   818 	margins are considered to be zero.</li>
   819 	<li>&nbsp;Immediately <em>before</em> pack and align steps, if there are any 
   820 	auto margins on items in the direction of alignment and there is positive 
   821 	free space, the free space is distributed equally to the auto margins. </li>
   822 	<li>If free space was distributed to auto margins, the following pack or align 
   823 	step has no effect.</li>
   824 </ul>
   825 <div class="example">
   826 <p>Auto margins can be used for simple alignment or for fine control.</p>
   827 	<p>Note that auto margins work consistently in both dimensions, so a simple 
   828 	markup like this</p>
   829 	<pre>div { 	display:flexbox;
   830 	width:4em; height:4em; background:silver;
   831 }
   832 p { margin:auto; }
   833 &lt;div&gt;&lt;p&gt;OK&lt;/p&gt;&lt;/div&gt;</pre>
   834 	<p>will center the single child:
   835 	<img alt="image of square OK button" height="82" src="images/OK.png" width="82"></p>
   836 	<p>And this</p>
   838 <pre>div {	display:flexbox;
   839 	width:calc(100% - 4em); height:calc(100% - 4em);
   840 	border: 1em solid blue; border-radius:50%;
   841 	margin:auto;
   842 }
   843 div#demo { width:9em; height:9em; }</pre>
   844 <pre>&lt;div id=&quot;demo&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</pre>
   845 <p>will produce nested centered boxes:
   846 <img alt="concentric blue circles" height="191" src="images/target.png" width="210"></p>
   847 </div>
   849 <h3 id='flex-line-pack'>
   850 'flex-line-pack' property</h3>
   852 	<table class=propdef>
   853 		<tr>
   854 			<th>Name:
   855 			<td><dfn>flex-line-pack</dfn>
   856 		<tr>
   857 			<th><a href="http://dev.w3.org/csswg/css-module/#values">Value</a>:
   858 			<td>start | end | center | justify | distribute | stretch
   859 		<tr>
   860 			<th>Initial:
   861 			<td>stretch
   862 		<tr>
   863 			<th>Applies to:
   864 			<td><i>multi-line</i> flexboxes
   865 		<tr>
   866 			<th>Inherited:
   867 			<td>no
   868 		<tr>
   869 			<th>Computed Value:
   870 			<td>specified value
   871 		<tr>
   872 			<th>Media:
   873 			<td>visual
   874 		<tr>
   875 			<th>Animatable:
   876 			<td>no
   877 	</table>
   879 	<p>The 'flex-line-pack' property aligns a flexbox's lines within the flexbox when there is extra space in the <i>cross axis</i>, similar to how 'flex-pack' aligns individual items within the <i>main axis</i>:</p>
   881 	<dl>
   882 		<dt><dfn id='flex-line-pack-start'>start</dfn></dt>
   883 		<dd>Lines are packed toward the start of the flexbox.  The <i>cross-start</i> edge of the first line in the flexbox is placed flush with the <i>cross-start</i> edge of the flexbox, and each subsequent line is placed flush with the preceding line.</dd>
   885 		<dt><dfn id='flex-line-pack-end'>end</dfn></dt>
   886 		<dd>Lines are packed toward the end of the flexbox.  The <i>cross-end</i> edge of the last line is placed flush with the <i>cross-end</i> edge of the flexbox, and each preceding line is placed flush with the subsequent line.</dd>
   888 		<dt><dfn id='flex-line-pack-center'>center</dfn></dt>
   889 		<dd>Lines are packed toward the center of the flexbox.  The lines in the flexbox are placed flush with each other and aligned in the center of the flexbox, with equal amounts of empty space between the <i>cross-start</i> content edge of the flexbox and the first line in the flexbox and between the <i>cross-end</i> content edge of the flexbox and the last line in the flexbox.  (If the leftover free-space is negative, the lines will overflow equally in both directions.)</dd>
   891 		<dt><dfn id='flex-line-pack-justify'>justify</dfn></dt>
   892 		<dd>Lines are evenly distributed in the flexbox.  If the leftover free-space is negative or there is only a single line in the flexbox, this value is identical to ''start''.  Otherwise, the <i>cross-start</i> edge of the first line in the flexbox is placed flush with the <i>cross-start</i> content edge of the flexbox, the <i>cross-end</i> edge of the last line in the flexbox is placed flush with the <i>cross-end</i> content edge of the flexbox, and the remaining lines in the flexbox are distributed so that the empty space between any two adjacent lines is the same.</dd>
   894 		<dt><dfn id='flex-line-pack-distribute'>distribute</dfn></dt>
   895 		<dd>Lines are evenly distributed in the flexbox, with half-size spaces on either end.  If the leftover free-space is negative or there is only a single line in the flexbox, this value is identical to ''center''.  Otherwise, the lines in the flexbox are distributed such that the empty space between any two adjacent lines is the same, and the empty space before the first and after the last lines in the flexbox are half the size of the other empty spaces.</dd>
   897 		<dt><dfn id='flex-line-pack-stretch'>stretch</dfn></dt>
   898 		<dd>Lines stretch to take up the remaining space.  If the leftover free-space is negative, this value is identical to ''start''.  Otherwise, the free-space is split equally between all of the lines, increasing their cross size.
   899 	</dl>
   901 	<p class='note'>Note: Only <i>multi-line</i> flexboxes ever have free space in the <i>cross axis</i> for lines to be aligned in, because in a <i>single-line</i> flexbox the sole line automatically stretches to fill the space.</p>
   903 	<p class="issue">TODO: examples</p>
   906 <h2 id='layout-algorithm'>
   907 Flexbox Layout Algorithm</h2>
   909 	<p>This section contains normative algorithms detailing the exact layout behavior of a flexbox and its contents.  The algorithms here were designed to optimize readability and theoretical simplicity, and may not necessarily be the most efficient.  Implementations may use whatever actual algorithms they wish, but must produce the same results as the algorithms described here.</p>
   911 	<div class=note>
   912 		<p>This note will outline the general structure of the layout algorithm, before I go into the ugly details below, to aid in reading the relatively-long and complex algorithm.</p>
   914 		<ol>
   915 			<li value=0>Generate anonymous flexbox items as necessary.</li>
   917 			<li>Reorder flexbox items according to 'flex-order'.</li>
   919 			<li>Find the hypothetical main size of every flexbox item.</li>
   921 			<li>Linebreak the flexbox, if it's multi-line.</li>
   923 			<li>Based on the hypothetical sizes of the items, find the real main size of the flexbox.</li>
   925 			<li>Resolve any flexible lengths.  All items now have a real main size.</li>
   927 			<li>Update layout for the items based on their real main sizes, and determine their hypothetical cross size.</li>
   929 			<li>Find the real cross size of the flexbox and its lines.</li>
   931 			<li>Align the lines, per 'flex-line-pack'.</li>
   933 			<li>Align in the cross axis, per 'flex-align'.</li>
   935 			<li>Update layout for the items based on their real cross sizes.</li>
   937 			<li>Align in the main axis, per 'flex-pack'.</li>
   938 		</ol>
   939 	</div>
   941 	<p>This section is mainly intended for implementors.  Authors writing web pages should generally be served well by the individual property descriptions, and do not need to read this section unless they have a deep-seated urge to understand arcane details of CSS layout.</p>
   943 	<p>To lay out a flexbox and its contents, follow these steps:</p>
   945 	<ol>
   946 		<li value=0>Generate anonymous flexbox items around runs of contiguous inline content in the flexbox, as described in the <a href="#flex-items">Flexbox Items</a> section.</li>
   948 		<li>Re-order the flexbox items according to their 'flex-order'.  The items with the lowest (most negative) 'flex-order' values are first in the ordering.  If multiple items share a 'flex-order' value, they're ordered by document order.  This affects the order in which the flexbox items generate boxes in the box-tree, and how the rest of this algorithm deals with the items.</li>
   950 		<li>
   951 			Determine the hypothetical main size of items:
   953 			<ol>
   954 				<li>If item has a definite preferred size, it is the hypothetical main size. </li>
   956 				<li>
   957 					<p>Otherwise layout the flexbox items using the shrink-to-fit algorithm.</p>
   959 					<p>Calculation of the shrink-to-fit width is similar to calculating the width of a table cell using the automatic table layout algorithm. Roughly: calculate the preferred width by formatting the content without breaking lines other than where explicit line breaks occur, and also calculate the preferred minimum width, e.g., by trying all possible line breaks. This module doesn&#39;t define the exact algorithm, but it is expected that the shrink-to-fit size is calculated the same way as it is for floats, except in this case it is not affected by available space.</p>
   961 					<div class="issue"><p>TODO: define shrink-to-fit. It works 
   962 						differently in row/column flexboxes:</p>
   963 						<ul>
   964 							<li>In horizontal, STF is max-content. </li>
   965 							<li>In vertical, cross-axis 
   966 					alignment has to happen first, then main-axis STF size can 
   967 					be calculated. In multi-line vertical (tricky case), auto 
   968 							sizes on cross axis are resolved as if it was 
   969 							single-line.</li>
   970 						</ul>
   971 					</div>
   972 				</li>
   973 			</ol>
   975 			<p><em>Do not apply min/max-width/height constraints to the preferred size of flexible lengths - those constraints are handled elsewhere in this algorithm, and doing so will produce incorrect results. </em></p>
   976 		</li>
   978 		<li>
   979 			<p>If the flexbox is single-line, collect all the flexbox items into a single flexbox line.</p>
   980 		</li>
   982 		<li>
   983 			<p>If the flexbox is multi-line, group the flexbox items into multiple lines:</p>
   985 			<ol>
   986 				<li>
   987 					<p>Determine the maximum line length, based on the main size of the flexbox. The maximum line length is main size of the flexbox's content box, constrained by the min and max main size constraints of the flexbox.  If the main size depends on the flexbox's content, then:</p>
   989 					<ul>
   990 						<li>for ''min-content'', the maximum line length is the flexbox's minimum main size, constrained by the min and max main size constraints of the flexbox.</li>
   992 						<li>for ''max-content'', the maximum line length is infinity, constrained by the min and max main size constraints of the flexbox.</li>
   994 						<li>for ''fit-content'', the maximum line length is the greater of the flexbox's min size constraint and the smaller of the flexbox's max size constraint and the available space.</li>
   995 					</ul>
   996 				</li>
   998 				<li>Collect as many consecutive flexbox items as possible, starting from the first item, while keeping the sum of their main size smaller than the flexbox's available space.  If a flexbox item is sized with a flexible length, then for the purpose of this step, clamp the item's size between its minimum and maximum main sizes.  The items so collected form a single flexbox line.</li>
  1000 				<li>Repeat the previous step, starting each time from the first flexbox item not yet collected into a flexbox line, until all flexbox items have been collected into flexbox lines.</li>
  1001 			</ol>
  1002 		</li>
  1004 		<li>Find the actual main size of the flexbox.  If the flexbox's main size doesn't rely on its contents, its actual main size is calculated per the appropriate rules.  Otherwise, its main size is the length of its longest line, calculated by summing the main sizes of the margin boxes of each flexbox item in the line, constrained by the flexbox's min and max main size constraints. 
  1005 		If any margins are set to &#39;auto&#39;, consider them to be set to zero until 
  1006 		resolved in a separate step.</li>
  1008 		<li>For each flexbox line, 
  1009 		<ol>
  1010 			<li><i>Resolve the flexible lengths</i> of the items contained within it.  All flexbox items now have a final main size.  Update each item's hypothetical cross size based on this main size.</li>
  1012 			<li>Calculate the leftover free-space by subtracting the sum of the 
  1013 			margin-box main sizes of the items on the line from the main size of the flexbox's content box.</li>
  1014 			<li>Resolve &#39;auto&#39; margins on main axis:<ol>
  1015 				<li>If leftover free-space is positive and any items on this 
  1016 				line have at least one main-axis margin set to &#39;auto&#39;, 
  1017 				distribute the leftover free-space equally to these margins.</li>
  1018 				<li>If leftover free-space is negative, any main-axis &#39;auto&#39; 
  1019 				margins on items in this line are set to zero.</li>
  1020 			</ol>
  1021 			</li>
  1022 			<li>
  1023 			Align the items along the main axis per 'flex-pack'.
  1024 			</li>
  1025 		</ol>
  1026 		</li>
  1028 		<li>Calculate the cross size of each flexbox line. For each flexbox 
  1029 		line:
  1030 			<ol>
  1031 				<li>If the flexbox is single-line and has a definite cross size, the single flexbox line's cross size is the cross size of the flexbox's content box.  End this step of the algorithm.</li>
  1033 				<li>If main axis is parallel to inline axis, collect all the flexbox items with a 'flex-item-align' of 'baseline'. Find the maximum of the distances from their baseline to the cross-start edge of their margin box, and the maximum of the distances from their baseline to the cross-end edge of their margin box. Sum these two values.</li>
  1035 				<li>For remaining flexbox items, find the maximum of the cross sizes of their margin boxes.
  1037 				<li>The cross size of the flexbox line is the larger of the numbers found in the previous two steps.</li>
  1038 				<li>If the flexbox is multi-line, has a definite cross size, 
  1039 				&#39;flex-line-pack&#39; is set to &#39;stretch&#39; and sum of cross size of 
  1040 				all lines is less than cross size of content box, increase cross 
  1041 				size of each line by equal amount to exactly match the cross 
  1042 				size of content box.</li>
  1043 			</ol>
  1044 		</li>
  1046 		<li>If the flexbox doesn't have a definite cross size, the cross size of its content box is the sum of the cross sizes of all of its lines.</li>
  1048 		<li>Determine the final cross size of each flexbox item.  For each flexbox item, if it has ''flex-item-align:stretch'', its final cross size is 
  1049 		set so that its margin-box cross size is equal to cross-size of its flexbox line.  For all other flexbox items, its final cross size is its hypothetical cross size. 
  1050 		If the result conflicts with &#39;min-width&#39;, &#39;max-width&#39;, &#39;min-height&#39; or 
  1051 		&#39;max-height&#39;, correct the result to comply the restrictions.</li>
  1052 		<p class="issue">'auto' height must only grow, not shrink here</p>
  1054 		<li>Resolve &#39;auto&#39; margins on cross axis. For each flexbox item, if its 
  1055 		margin box cross size is smaller than cross size of its line and it has 
  1056 		any margins in cross direction set to &#39;auto&#39;, distribute the difference 
  1057 		equally to the auto margins. </li>
  1058 		<li>For each flexbox line, align the flexbox items per 'flex-item-align'.</li>
  1060 		<li>Align the flexbox lines per 'flex-line-pack'.  The leftover free-space is calculated by subtracting the sum of the flexbox line's cross sizes from the cross size of the flexbox's content box.</li>
  1061 		<li>Layout all items again in their final size and position. 
  1062 		Implementations can determine when this step is needed and how it can be 
  1063 		optimized, but for precise results it has to be assumed that this step 
  1064 		is performed, because the layout of each item&#39;s content may change when 
  1065 		ea</li>
  1066 	</ol>
  1068 	<p>To <dfn>resolve the flexible lengths</dfn> of the items within a flexbox line:</p>
  1070 	<ol>
  1071 		<li>
  1072 			Determine sign of flexibility
  1074 			<ol>
  1075 				<li>Add sizes of all items, <i>adjusted for min/max</i>.
  1077 				<li>If sum of preferred sizes is less than available space, use positive flexibility, otherwise use negative flexibility.</li>
  1078 			</ol>
  1080 			<p>for the rest of the algorithm use flexibility with the sign determined in this step</p>
  1081 		</li>
  1083 		<li>Reset all flexible sizes to their preferred size</li>
  1085 		<li>Find free space by subtracting sum of item sizes from available space.</li>
  1087 		<li>
  1088 			Distribute free space proportional to flex:
  1090 			<ol>
  1091 				<li>If the free space is positive, but step 1 chose negative flexibility, do nothing</li>
  1093 				<li>If the free space is negative, but step 1 chose positive flexibility, do nothing</li>
  1095 				<li>Add a portion of free space to each flexible item, 
  1096 				proportional to item's flexibility</li>
  1097 			</ol>
  1098 		</li>
  1100 		<li>
  1101 			Fix min/max violations:
  1103 			<ol>
  1104 				<li>Adjust each flexible item for min/max. </li>
  1106 				<li>If the size has changed, it is a violation. </li>
  1108 				<li>The violation may be positive (min violation) or negative (max violation). Accumulate the difference.</li>
  1109 			</ol>
  1110 		</li>
  1112 		<li>
  1113 			If the sum of all violations is:
  1115 			<dl>
  1116 				<dt>Zero</dt>
  1117 				<dd>Exit the algorithm.</dd>
  1119 				<dt>Positive</dt>
  1120 				<dd>Freeze items with max violations, and return to step 2.</dd>
  1122 				<dt>Negative</dt>
  1123 				<dd>Freeze items with min violations, and return to step 2.</dd>
  1124 			</dl>
  1125 		</li>
  1126 	</ol>
  1128 <h2 id="pagination">
  1129 Page breaks in flexbox</h2>
  1131 	<p>Flexboxes can break across pages between items, between lines of items (in multi-line mode) and inside items, as long as 'break-' property allow that. All 'break-' properties are supported on flexbox, on flexbox items and inside flexbox items.</p>
  1133 	<p>The following breaking rules refer to fragmentation container as “page”. The same rules apply to any other fragmenters. Change “page” to the appropriate fragmenter type as needed.</p>
  1135 	<p>Breaks in and around flexbox are determined as follows:</p>
  1137 	<ol>
  1138 		<li> Break-before, break-after, break-inside properties on flexbox itself have effect as normal. If breaks inside flexbox are allowed, break points are determined using following rules.</li>
  1140 		<li>When flexbox is continued after a break, flexbox’s available space in block direction is reduced by space consumed in previous pages. Consumed space before page break is:
  1142 			<ol>
  1143 				<li>If flexbox starts on that page: the distance between start of content box of the flexbox and the end of available space</li>
  1145 				<li>If flexbox continues from previous page: the size of available space.</li>
  1146 			</ol>
  1148 			<p>If as a result of this adjustment block-direction size of flexbox becomes negative, it is set to zero.</p>
  1149 		</li>
  1151 		<li>
  1152 			<dfn>Forced breaks on flexbox items</dfn>
  1154 			<ol>
  1155 				<li>In a row-direction single-line flexbox, breaks before and after items apply to the flexbox</li>
  1156 				<p class="issue">"break-inside:avoid" in single-line horizontal should probably be applied to flexbox too.</p>
  1158 				<li>In column-direction single-line flexbox and all multi-line flexboxes:
  1160 					<ol>
  1161 						<li>Forced break before the first item is applied to the flexbox</li>
  1163 						<li>Forced break after the last item is applied to the flexbox</li>
  1165 						<li>Forced break before or after any other item terminates the set of items to be laid out on this page</li>
  1166 					</ol>
  1167 				</li>
  1168 			</ol>
  1170 		</li>
  1172 		<li>When necessary, a <dfn>break inside a flexbox item is considered</dfn> as follows:
  1174 			<ol>
  1175 				<li>If the item has “break-inside:avoid”, it is pushed to the next page</li>
  1177 				<li>Otherwise, it may be broken, according to breaking rules and algorithms applicable to its display type. </li>
  1179 				<li>Forced breaks inside flexbox item content are handled normally, but in row-direction flexbox they don&#39;t affect layout of sibling 
  1180 				flexbox items (e.g. a forced break inside an item doesn&#39;t prevent its next sibling from appearing on the same page)</li>
  1181 			</ol>
  1182 		</li>
  1184 		<li>
  1185 			<b>Column-direction flexbox: single-line</b>
  1187 			<ol>
  1188 				<li>
  1189 					<p>If flexbox main-axis size is definite, flexbox algorithm must be run first, without constraints of available space on page and using all content of the flexbox. Otherwise items use the preferred size, adjusted for min/max.</p>
  1191 					<p>If page size varies and flexbox size depends on page size, this step has to be repeated on each page, again with the whole content of the flexbox.</p>
  1192 				</li>
  1194 				<li>Set of items that will fit on current page is determined by adding main-axis sizes of items until total size exceeds 
  1195 				available space or a forced break is encountered.</li>
  1197 				<li>If border box of an item doesn’t fit in available space, a break inside the item is considered</li>
  1199 				<li>
  1200 					<p>Items that fit on a page completely or partially are aligned according to ‘flex-pack’ property, independently from the rest of flexbox content.</p>
  1202 					<p>Note that flexible lengths are not recalculated on each page, even if there is additional free space.</p>
  1203 				</li>
  1204 			</ol>
  1206 			<p class="note">It is the intent of this spec that column-direction single-line flexbox paginates very 
  1207 			similarly to block flow. As a test of the intent, a flexbox with "flex-pack:start" and no flexible items should paginate identically to a block with non-floating children with same content, same used size and same used margins. This rule is simplified and not normative, but if there is any difference it should be noted here.</p>
  1208 		</li>
  1210 		<li>
  1211 			<b>Column-direction flexbox: multi-line</b>
  1213 			<ol>
  1214 				<li>Items are collected in lines and laid out as usual, but in available space on current page.</li>
  1216 				<li>If border box of an item doesn’t fit on main-axis and it is 
  1217 				the only item in its line:
  1218 					<ol>
  1219 						<li>If the flexbox is not at the top of the page, it is moved to the next page.</li>
  1221 						<li>If the flexbox is already at the top of the page, the item may produce overflow. If 'overflow' property of the flexbox is set to 'visible', it is paginated using same rules as visible overflow of blocks in normal flow.
  1223 							<p class="note">After the break, continuation of overflow items may overlap with other items and/or content after the flexbox. It is undesirable but there is no good resolution for this spacial conflict and this outcome is similar to effect of "overflow:visible" elsewhere.</p>
  1224 						</li>
  1225 							</ol>
  1226 						</li>
  1227 					</ol>
  1228 				</li>
  1229 				<li>Breaks inside items (forced or unforced) are not allowed</li>
  1230 			</ol>
  1231 		</li>
  1233 		<li>
  1234 			<b>Row-direction flexbox: single-line</b>
  1236 			<ol>
  1237 				<li>
  1238 					<p>Main-axis space distribution in each line is done based on complete content of the flexbox and without space constraint in block direction.</p>
  1240 					<p>If page size varies and flexbox size depends on page size, this step needs to be repeated on each page.</p>
  1241 				</li>
  1243 				<li>Items are sized and positioned as usual, but in block-direction available space of min(remaining available space in flexbox, remaining space on the page).</li>
  1245 				<li>Any items with baseline alignment must be aligned before considering breaks inside items.</li>
  1247 				<li>If border box of an item doesn’t fit in current page, a break inside the item is considered</li>
  1249 				<li>Items that have fit completely on a previous page and items that are pushed to next page don’t have any rendering, leaving empty space as needed.</li>
  1251 				<li>Items that fit completely or partially on current page are aligned on cross-axis:
  1253 					<ol>
  1254 						<li>For the purposes of cross-axis alignment, minimum of remaining available space in flexbox and available space at current page is used.</li>
  1256 						<li>If an item is broken in the previous step and its alignment is not baseline, its cross-axis size is set to available space. If item alignment is baseline, its cross-axis size is adjusted so that it extends to exactly the end of available space.</li>
  1257 					</ol>
  1258 				</li>
  1259 			</ol>
  1260 		</li>
  1262 		<li>
  1263 			<b>Row-direction flexbox:multi-line</b>
  1265 			<ol>
  1266 				<li>Collect items into lines and determine line heights:
  1268 					<ol>
  1269 						<li>
  1270 							<p>If 'flex-line-pack' is 'stretch' and flexbox size in block direction is definite, layout of the complete flexbox has to be done first to determine line heights. Layout is done as usual for non-paginated case, but accounting for forced breaks.</p>
  1272 							<p>If page size varies, this step may have to be redone, again with complete content; special consideration should be to be given to line breaks to ensure that item at the start of current page is also at the start of a line in this hypothetical layout. This specification currently doesn't define how exactly to achieve that.</p>
  1273 						</li>
  1275 						<li>Otherwise, items are collected into lines and each line is laid out as a single-line flexbox to determine block-direction size of each line.</li>
  1276 					</ol>
  1277 				</li>	
  1279 				<li>Lines are added one at a time, until out of available space or a forced break is encountered</li>
  1281 				<li>Breaks inside items (forced or unforced) are not allowed.</li>
  1282 				<li>If the first flexbox line on a page doesn&#39;t fit in 
  1283 				cross-axis,
  1284 				<ol>
  1285 					<li>If the flexbox is not at the top of the page, it is moved to the next page.</li>
  1286 					<li>If the flexbox is already at the top of the page, the item may produce overflow. If 'overflow' property of the flexbox is set to 'visible', it is paginated using same rules as visible overflow of blocks in normal flow.</li>
  1287 				</ol>
  1288 				</li>
  1290 				<li>If size of flexbox in inline direction is not definite, multi-line layout algorithm is run using the set of items 
  1291 				that have fit on the current page.</li>
  1293 				<li>Line packing is done on each page, with content on the page</li>
  1294 				<p class="issue">TODO: combine breaking algorithms for multiline in both directions. If breaks inside items are not allowed the algorithm is almost same.</p>
  1295 			</ol>
  1296 		</li>
  1297 	</ol>
  1299 <h2 id="conformance">
  1300 Conformance</h2>
  1302 <h3 id="conventions">
  1303 Document conventions</h3>
  1305   <p>Conformance requirements are expressed with a combination of
  1306   descriptive assertions and RFC 2119 terminology. The key words “MUST”,
  1308   “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
  1309   document are to be interpreted as described in RFC 2119.
  1310   However, for readability, these words do not appear in all uppercase
  1311   letters in this specification.
  1313   <p>All of the text of this specification is normative except sections
  1314   explicitly marked as non-normative, examples, and notes. [[!RFC2119]]</p>
  1316   <p>Examples in this specification are introduced with the words “for example”
  1317   or are set apart from the normative text with <code>class="example"</code>,
  1318   like this:
  1320   <div class="example">
  1321     <p>This is an example of an informative example.</p>
  1322   </div>
  1324   <p>Informative notes begin with the word “Note” and are set apart from the
  1325   normative text with <code>class="note"</code>, like this:
  1327   <p class="note">Note, this is an informative note.</p>
  1329 <h3 id="conformance-classes">
  1330 Conformance classes</h3>
  1332   <p>Conformance to CSS Flexbox Layout Module
  1333   is defined for three conformance classes:
  1334   <dl>
  1335     <dt><dfn title="style sheet!!as conformance class">style sheet</dfn>
  1336       <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#style-sheet">CSS
  1337       style sheet</a>.
  1338     <dt><dfn>renderer</dfn></dt>
  1339       <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
  1340       that interprets the semantics of a style sheet and renders
  1341       documents that use them.
  1342     <dt><dfn id="authoring-tool">authoring tool</dfn></dt>
  1343       <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
  1344       that writes a style sheet.
  1345   </dl>
  1347   <p>A style sheet is conformant to CSS Flexbox Layout Module
  1348   if all of its statements that use syntax defined in this module are valid
  1349   according to the generic CSS grammar and the individual grammars of each
  1350   feature defined in this module.
  1352   <p>A renderer is conformant to CSS Flexbox Layout Module
  1353   if, in addition to interpreting the style sheet as defined by the
  1354   appropriate specifications, it supports all the features defined
  1355   by CSS Flexbox Layout Module by parsing them correctly
  1356   and rendering the document accordingly. However, the inability of a
  1357   UA to correctly render a document due to limitations of the device
  1358   does not make the UA non-conformant. (For example, a UA is not
  1359   required to render color on a monochrome monitor.)
  1361   <p>An authoring tool is conformant to CSS Flexbox Layout Module
  1362   if it writes style sheets that are syntactically correct according to the
  1363   generic CSS grammar and the individual grammars of each feature in
  1364   this module, and meet all other conformance requirements of style sheets
  1365   as described in this module.
  1367 <h3 id="partial">
  1368 Partial implementations</h3>
  1370   <p>So that authors can exploit the forward-compatible parsing rules to
  1371   assign fallback values, CSS renderers <strong>must</strong>
  1372   treat as invalid (and <a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignore
  1373   as appropriate</a>) any at-rules, properties, property values, keywords,
  1374   and other syntactic constructs for which they have no usable level of
  1375   support. In particular, user agents <strong>must not</strong> selectively
  1376   ignore unsupported component values and honor supported values in a single
  1377   multi-value property declaration: if any value is considered invalid
  1378   (as unsupported values must be), CSS requires that the entire declaration
  1379   be ignored.</p>
  1381 <h3 id="experimental">
  1382 Experimental implementations</h3>
  1384   <p>To avoid clashes with future CSS features, the CSS2.1 specification
  1385   reserves a <a href="http://www.w3.org/TR/CSS21/syndata.html#vendor-keywords">prefixed
  1386   syntax</a> for proprietary and experimental extensions to CSS.
  1388   <p>Prior to a specification reaching the Candidate Recommendation stage
  1389   in the W3C process, all implementations of a CSS feature are considered
  1390   experimental. The CSS Working Group recommends that implementations
  1391   use a vendor-prefixed syntax for such features, including those in
  1392   W3C Working Drafts. This avoids incompatibilities with future changes
  1393   in the draft.
  1394   </p>
  1396 <h3 id="testing">
  1397 Non-experimental implementations</h3>
  1399   <p>Once a specification reaches the Candidate Recommendation stage,
  1400   non-experimental implementations are possible, and implementers should
  1401   release an unprefixed implementation of any CR-level feature they
  1402   can demonstrate to be correctly implemented according to spec.
  1404   <p>To establish and maintain the interoperability of CSS across
  1405   implementations, the CSS Working Group requests that non-experimental
  1406   CSS renderers submit an implementation report (and, if necessary, the
  1407   testcases used for that implementation report) to the W3C before
  1408   releasing an unprefixed implementation of any CSS features. Testcases
  1409   submitted to W3C are subject to review and correction by the CSS
  1410   Working Group.
  1412   <p>Further information on submitting testcases and implementation reports
  1413   can be found from on the CSS Working Group's website at
  1414   <a href="http://www.w3.org/Style/CSS/Test/">http://www.w3.org/Style/CSS/Test/</a>.
  1415   Questions should be directed to the
  1416   <a href="http://lists.w3.org/Archives/Public/public-css-testsuite">public-css-testsuite@w3.org</a>
  1417   mailing list.
  1419 <h3 id="cr-exit-criteria">
  1420 CR exit criteria</h3>
  1422   <p>
  1423   For this specification to be advanced to Proposed Recommendation,
  1424   there must be at least two independent, interoperable implementations
  1425   of each feature. Each feature may be implemented by a different set of
  1426   products, there is no requirement that all features be implemented by
  1427   a single product. For the purposes of this criterion, we define the
  1428   following terms:
  1430   <dl>
  1431     <dt>independent <dd>each implementation must be developed by a
  1432     different party and cannot share, reuse, or derive from code
  1433     used by another qualifying implementation. Sections of code that
  1434     have no bearing on the implementation of this specification are
  1435     exempt from this requirement.
  1437     <dt>interoperable <dd>passing the respective test case(s) in the
  1438     official CSS test suite, or, if the implementation is not a Web
  1439     browser, an equivalent test. Every relevant test in the test
  1440     suite should have an equivalent test created if such a user
  1441     agent (UA) is to be used to claim interoperability. In addition
  1442     if such a UA is to be used to claim interoperability, then there
  1443     must one or more additional UAs which can also pass those
  1444     equivalent tests in the same way for the purpose of
  1445     interoperability. The equivalent tests must be made publicly
  1446     available for the purposes of peer review.
  1448     <dt>implementation <dd>a user agent which:
  1450     <ol class=inline>
  1451       <li>implements the specification.
  1453       <li>is available to the general public. The implementation may
  1454       be a shipping product or other publicly available version
  1455       (i.e., beta version, preview release, or “nightly build”). 
  1456       Non-shipping product releases must have implemented the
  1457       feature(s) for a period of at least one month in order to
  1458       demonstrate stability.
  1460       <li>is not experimental (i.e., a version specifically designed
  1461       to pass the test suite and is not intended for normal usage
  1462       going forward).
  1463     </ol>
  1464   </dl>
  1466   <p>The specification will remain Candidate Recommendation for at least
  1467   six months.
  1470 <hr title="Separator from footer">
  1472 <h2 class="no-num" id="acknowledgments">Acknowledgments</h2>
  1474 	<p>Thanks for feedback and contributions to 	
  1476 Andrew Fedoniouk,
  1477 Arron Eicholz, 
  1478 James Elmore,
  1479 Ben Horst,
  1480 Boris Zbarsky,
  1481 Brad Kemper,
  1482 Brian Heuston,
  1483 Christian Stockwell,
  1484 Christoph Päper,
  1485 Daniel Holbert,
  1486 Erik Anderson,
  1487 Eugene Veselov, 
  1488 Fantasai,
  1489 John Jansen, 
  1490 Markus Mielke, 
  1491 Ning Rogers,
  1492 Ojan Vafai,
  1493 Peter Salas,
  1494 Phil Cupp, 
  1495 Robert O'Callahan,
  1496 Rossen Atanassov, 
  1497 Shinichiro Hamaji,
  1498 Tony Chang.
  1500 	</p>
  1503 <h2 class="no-num" id="references">References</h2>
  1505 <h3 class="no-num" id="normative">Normative references</h3>
  1506 <!--normative-->
  1508 <h3 class="no-num" id="informative">Other references</h3>
  1509 <!--informative-->
  1511 <h2 id="property" class="no-num">Property index</h2>
  1512 <!--properties-->
  1514 <h2 class="no-num" id="index">Index</h2>
  1515 <!--index-->
  1517 </body></html>
  1518 <!-- Keep this comment at the end of the file
  1519 Local variables:
  1520 mode: sgml
  1521 sgml-declaration:"~/SGML/HTML4.decl"
  1522 sgml-default-doctype-name:"html"
  1523 sgml-minimize-attributes:t
  1524 sgml-nofill-elements:("pre" "style" "br")
  1525 sgml-live-element-indicator:t
  1526 sgml-omittag:nil
  1527 sgml-shorttag:nil
  1528 sgml-namecase-general:t
  1529 sgml-general-insert-case:lower
  1530 sgml-always-quote-attributes:t
  1531 sgml-indent-step:nil
  1532 sgml-indent-data:t
  1533 sgml-parent-document:nil
  1534 sgml-exposed-tags:nil
  1535 sgml-local-catalogs:nil
  1536 sgml-local-ecat-files:nil
  1537 End:
  1538 -->