<pre class='metadata'>
Title: CSS Flexible Box Layout Module Level 1
Shortname: css-flexbox
Level: 1
Status: ED
Prepare for TR: no
Work Status: Testing
Group: csswg
ED: https://drafts.csswg.org/css-flexbox/
TR: https://www.w3.org/TR/css-flexbox-1/
Implementation Report: https://wpt.fyi/results/css/css-flexbox
Abstract: The specification describes a CSS box model optimized for user interface design. In the flex layout model, the children of a flex container 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.
Editor: Tab Atkins Jr., Google, http://xanthir.com/contact/, w3cid 42199
Editor: Elika J. Etemad / fantasai, Apple, http://fantasai.inkedblade.net/contact, w3cid 35400
Editor: Rossen Atanassov, Microsoft, ratan@microsoft.com, w3cid 49885
Former Editor: Alex Mogilevsky, Microsoft Corporation, alexmog@microsoft.com
Former Editor: L. David Baron, Google https://www.google.com/, https://dbaron.org/, w3cid 15393
Former Editor: Neil Deakin, Mozilla Corporation, enndeakin@gmail.com
Former Editor: Ian Hickson, formerly of Opera Software, ian@hixie.ch
Former Editor: David Hyatt, formerly of Netscape Corporation, hyatt@apple.com
!Issues List: <a href="https://drafts.csswg.org/css-flexbox-1/issues">https://drafts.csswg.org/css-flexbox-1/issues</a>
Ignored Terms: auto, first formatted line, first letter
Ignored Vars: item’s own max-content, maximum min-content among all items
WPT Path Prefix: css/css-flexbox/
WPT Display: closed
</pre>

<pre class='link-defaults'>
spec: css2; type: property
	text: margin
	text: min-width
	text: max-width
	text: min-height
	text: max-height
spec: css-break-3; type: property; text: break-after
spec: css-sizing-3;
	type: value;
		for: width
			text: min-content
			text: max-content
			text: fit-content
	type: property; text: box-sizing
	type:dfn;
		text: width
		text: height
spec: css-align-3;
	type: value; text: start
	type:dfn; text:alignment baseline
spec: css-position-3; type: property; text: left
spec: css-writing-modes-3; type: dfn;
	text: start
	text: end
spec: css-pseudo-4; type: selector;
	text: ::first-line
	text: ::first-letter
</pre>

<style>
img { background: transparent; }

code.one-line { white-space: pre;  }
.code-and-figure {
	display: table;
	margin: 0 auto;
	border-spacing: 1em;
}
.code-and-figure > div {
	display: table-cell;
	vertical-align: middle;
}

ol.layout-start { counter-reset: list 0; }
ol.layout-start,
ol.continue { list-style: none; }
ol.layout-start > li,
ol.continue > li { position: relative; counter-increment: list; }
ol.layout-start > li::before,
ol.continue > li::before { content: counter(list) "."; position: absolute; left: -4.5em; width: 4em; text-align: right; }
.compact, .compact li {
	margin-top: 0;
	margin-bottom: 0;
}

/* Overview catalog example */
#overview-example {
	display:table;
	margin: 0 auto 1em;
	border-spacing: .5em 0;
	min-width: 672px;
	color: black;
}
#overview-example > .col {
	display: table-column;
	background: hsl(60,100%,90%);
}
#overview-example > .desc {
	display: table-cell;
	vertical-align: top;
	width: 300px;
	padding: 1em 1em 0;
	text-align: left;
	border: thick solid hsl(60,80%,50%);
	border-radius: 1em 1em 0 0;
	border-bottom: none;
}
#overview-example > .desc > img {
	margin: 0 auto;
	display: block;
}
#overview-example > .desc > h1 {
	background: transparent;
}
#overview-example > .buttons {
	display: table-row;
}
#overview-example > .buttons > div {
	display: table-cell;
	border: thick solid hsl(60,80%,50%);
	border-radius: 0 0 1em 1em;
	border-top: none;
	text-align: center;
}
#overview-example button {
	background-color: hsl(120,100%,40%);
	border: medium inset hsl(120,70%,40%);
	border-radius: 1em;
	padding: .5em;
	font-weight: bold;
	color: white;
	font-size: 1.6em;
	cursor: pointer;
	width: 90%;
	margin: 1em auto;
}

/* Visibility: Collapse example */
#visibility-collapse-example {
	display: table;
	width: 100%;
	box-shadow: 3px 3px 10px canvas;
}
#visibility-collapse-example > article,
#visibility-collapse-example > nav {
	display: table-cell;
}
#visibility-collapse-example > article {
	width: 100%;
	background: canvas;
}
#visibility-collapse-example ul,
#visibility-collapse-example li {
	list-style: none;
	margin: 0;
	padding: 0;
}
#visibility-collapse-example > nav > ul {
	background: #444;
	border-radius: 0.5em;
	padding: 0.075em;
}
#visibility-collapse-example li {
	padding: 0 0.5em;
	background: #ddd;
	color: black;
	border-radius: 0.40em;
	border: #444 solid 0.075em;
	white-space: nowrap;
}
#visibility-collapse-example li li {
	background: #444;
	color: white;
	margin: 0 -0.5em;
	border-radius: 0;
}
#visibility-collapse-example li li:first-child {
	border-radius: 0.375em 0.375em 0 0;
}
#visibility-collapse-example a {
	background: transparent;
	color: inherit;
}
#visibility-collapse-example > nav > ul > li:target,
#visibility-collapse-example > nav > ul > li:hover {
	background: #888;
	color: white;
}
#visibility-collapse-example > nav > ul > li:not(:target):not(:hover) > ul {
	height: 0;
	overflow: hidden;
}

#auto-bar {
	overflow: hidden;
	padding: .25em 1em;
	background: #ddd;
	list-style: none;
	margin: 0;
	border-radius: .3em;
}
@media (prefers-color-scheme: dark) {
	#auto-bar { background: #444; }
}
#auto-bar > li {
	float: left;
	margin: 0;
}
#auto-bar > li:first-child:after,
#auto-bar > li:first-child + li:after {
	content: " |  ";
	white-space: pre;
}
#auto-bar > li > a {
	display: inline-block;
	padding: 0 .25em;
	border-radius: .3em;
	border: none;
	background: transparent;
}
#auto-bar > li > a:not(:hover):not(:focus) {
	text-decoration: none;
}
#auto-bar > li > a:hover {
	color: #ddd;
	background: #444;
}
#auto-bar > #login { float: right; }


.cross-auto-figure > div {
	margin: 0 auto;
	width: 70px;
	background: #888;
	padding: 0 .5em;
	border-radius: 1em;
	border: 1px solid transparent;
}
.cross-auto-figure > div > div {
	border-spacing: 0;
	display: table;
	background: #ddd;
	color: black;
	text-align: center;
	margin: .5em auto;
	padding: .5em;
	border-radius: .5em;
}

.axis { color: hsl(  0,80%,40%); }
.side { color: hsl(240,80%,50%); }
.size { color: hsl(120,80%,30%); }
</style>

<h2 id="intro">
Introduction</h2>

	<em>This section is not normative.</em>

	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 2D data in a tabular format
	* positioned layout, designed for very explicit positioning without much regard for other elements in the document

	This module introduces a new layout mode, <dfn export>flex layout</dfn>,
	which is designed for laying out more complex applications and webpages.

<h3 id="overview">
Overview</h3>

	<em>This section is not normative.</em>

	Flex layout is superficially similar to block layout.
	It lacks many of the more complex text- or document-centric properties
	that can be used in block layout, such as
	<a href="https://www.w3.org/TR/CSS2/visuren.html#floats">floats</a> and
	<a href="https://www.w3.org/TR/css3-multicol/">columns</a>.
	In return it gains simple and powerful tools
	for distributing space and aligning content
	in ways that web apps and complex web pages often need.
	The contents of a flex container:

	* can be laid out in any <a href="#flex-direction-property">flow direction</a>
		(leftwards, rightwards, downwards, or even upwards!)
	* can have their display order <a value for="flex-direction" lt="row-reverse">reversed</a> or
		'order|rearranged' at the style layer
		(i.e., visual order can be independent of source and speech order)
	* can be laid out linearly along a single (<a lt="main axis">main</a>) axis or
		<a href="#flex-wrap-property">wrapped</a> into multiple lines along a secondary (<a lt="cross axis">cross</a>) axis
	* can <a href="#flexibility">&ldquo;flex&rdquo; their sizes</a>
		to respond to the available space
	* can be <a href="#alignment">aligned</a> with respect to their container or each other on the secondary (<a lt="cross axis">cross</a>)
	* can be dynamically <a href="#visibility-collapse">collapsed</a> or uncollapsed
		along the <a>main axis</a> while preserving the container's <a>cross size</a>

	<div class='example'>
		Here's an example of a catalog where each item has a title, a photo, a description, and a purchase button.
		The designer's intention is that each entry has the same overall size,
		that the photo be above the text,
		and that the purchase buttons are aligned at the bottom, regardless of the length of the item's description.
		Flex layout makes many aspects of this design easy:

		* The catalog uses flex layout to lay out rows of items horizontally,
			and to ensure that items within a row are all equal-height.
			Each entry is then itself a column flex container,
			laying out its contents vertically.

		* Within each entry, the source document content is ordered logically
			with the title first, followed by the description and the photo.
			This provides a sensible ordering for speech rendering and in non-CSS browsers.
			For a more compelling visual presentation, however,
			'order' is used to pull the image up from later in the content to the top,
			and 'align-self' is used to center it horizontally.

		* An <a href="#auto-margins"><css>auto</css> margin</a> above the purchase button
			forces it to the bottom within each entry box,
			regardless of the height of that item's description.

		<pre class="lang-css">
		#deals {
			display: flex;        /* Flex layout so items <a property lt="align-self">have equal height</a>  */
			flex-flow: row wrap;  /* <a section href="#flex-flow-property">Allow items to wrap into multiple lines</a> */
		}
		.sale-item {
			display: flex;        /* Lay out each item using flex layout */
			flex-flow: column;    /* <a section href="#flex-flow-property">Lay out item's contents vertically</a>  */
		}
		.sale-item > img {
			order: -1;            /* Shift image before other content (in visual order) */
			align-self: center;   /* <a property lt="align-self">Center the image cross-wise (horizontally)</a>         */
		}
		.sale-item > button {
			margin-top: auto;     /* <a section href="#auto-margins">Auto top margin pushes button to bottom</a> */
		}
		</pre>

		<pre class="lang-markup">
		&lt;section id="deals">
		  &lt;section class="sale-item">
		    &lt;h1>Computer Starter Kit&lt;/h1>
		    &lt;p>This is the best computer money can buy, if you don’t have much money.
		    &lt;ul>
		      &lt;li>Computer
		      &lt;li>Monitor
		      &lt;li>Keyboard
		      &lt;li>Mouse
		    &lt;/ul>
		    &lt;img src="images/computer.jpg"
		         alt="You get: a white computer with matching peripherals.">
		    &lt;button>BUY NOW&lt;/button>
		  &lt;/section>
		  &lt;section class="sale-item">
		    &hellip;
		  &lt;/section>
		  &hellip;
		&lt;/section>
		</pre>

		<figure>
			<div id="overview-example">
				<div class="col"></div>
				<div class="col"></div>
				<div class="desc">
					<img src="images/computer.jpg" alt="You get: a white computer with matching keyboard and monitor." width=250 height=188>
					<h1 id=quiet-pubrules-1 style="font-size: 1.4em;">Computer Starter Kit</h1>
					<p>
						This is the best computer money can buy,
						if you don't have much money.
					<ul>
						<li>Computer
						<li>Monitor
						<li>Keyboard
						<li>Mouse
					</ul>
				</div>
				<div class="desc">
					<img src="images/printer.png" alt="You get: beautiful ASCII art." width=159 height=188>
					<h1 id=quiet-pubrules-2 style="font-size: 1.4em;">Printer</h1>
					<p>
						Only capable of printing
						ASCII art.
					<ul>
						<li>Paper and ink not included.
					</ul>
				</div>
				<div class="buttons">
					<div><button>BUY NOW</button></div>
					<div><button>BUY NOW</button></div>
				</div>
			</div>
			<figcaption>
				An example rendering of the code above.
			</figcaption>
		</figure>
	</div>

<h3 id="placement">
Module interactions</h3>

	This module extends the definition of the 'display' property [[!CSS2]],
	adding a new block-level and new inline-level display type,
	and defining a new type of formatting context
	along with properties to control its layout.
	None of the properties defined in this module apply to the ''::first-line'' or ''::first-letter'' pseudo-elements.

	The <a href="http://www.w3.org/TR/css-align/">CSS Box Alignment Module</a>
	extends and supersedes the definitions of the alignment properties
	('justify-content', 'align-items', 'align-self', 'align-content')
	introduced here.

	<wpt>
		flexbox_first-letter.html
		flexbox_first-line.html
		getcomputedstyle/first-line-computed-style.html
		flexbox-ignores-first-letter.html
	</wpt>

<h3 id="values">
Value Definitions</h3>

	This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]]
	using the <a href="https://www.w3.org/TR/css-values-3/#value-defs">value definition syntax</a> from [[!CSS-VALUES-3]].
	Value types not defined in this specification are defined in CSS Values &amp; Units [[!CSS-VALUES-3]].
	Combination with other CSS modules may expand the definitions of these value types.

	In addition to the property-specific values listed in their definitions,
	all properties defined in this specification
	also accept the <a>CSS-wide keywords</a> as their property value.
	For readability they have not been repeated explicitly.

<h2 id='box-model'>
Flex Layout Box Model and Terminology</h2>

	A <dfn export>flex container</dfn> is the box generated by an element with a
	computed 'display' of ''flex'' or ''inline-flex''.
	<a>In-flow</a> children of a flex container are called <dfn export lt="flex item" id="flex-item">flex items</dfn>
	and are laid out using the flex layout model.

	Unlike block and inline layout,
	whose layout calculations are biased to the <a href="https://www.w3.org/TR/css3-writing-modes/#abstract-box">block and inline flow directions</a>,
	flex layout is biased to the <dfn export lt="flex direction">flex directions</dfn>.
	To make it easier to talk about flex layout,
	this section defines a set of flex flow&ndash;relative terms.
	The 'flex-flow' value and the <a>writing mode</a>
	determine how these terms map
	to physical directions (top/right/bottom/left),
	axes (vertical/horizontal), and sizes (width/height).

	<figure>
		<img src='images/flex-direction-terms.svg' width=665 height=277 alt>
		<figcaption>
			An illustration of the various directions and sizing terms as applied to a ''row'' flex container.
		</figcaption>
	</figure>

	<dl id="main" export>
		<dt class='axis'>main axis
		<dt class='axis'>main dimension
		<dd>
			The <dfn lt="main axis|main-axis">main axis</dfn> of a flex container is the primary axis along which <a>flex items</a> are laid out.
			It extends in the <dfn>main dimension</dfn>.

		<dt class='side'>main-start
		<dt class='side'>main-end
		<dd>
			The <a>flex items</a> are placed within the container
			starting on the <dfn>main-start</dfn> side
			and going toward the <dfn>main-end</dfn> side.

		<dt class='size'>main size
		<dt class='size'>main size property
		<dd>
			The <dfn>main size</dfn> of a [=flex container=] or [=flex item=]
			refers to its [=width=] or [=height=],
			whichever is in the [=main dimension=].
			Its <dfn>main size property</dfn>
			is either its 'width' or 'height' property,
			whichever is in the [=main dimension=].
			Likewise, its <dfn lt="min main size property">min</dfn> and
			<dfn lt="max main size property">max main size properties</dfn>
			are its 'min-width'/'max-width' or 'min-height'/'max-height' properties,
			whichever are in the <a>main dimension</a>,
			and determine its <dfn lt="min main size">min</dfn>/<dfn>max main size</dfn>.

			In [=flex layout=], the [=main size=] is controlled by the 'flex' property
			rather than directly by the [=main size property=].

			Note: This means any references to a flex item's used size in the [=main dimension=]
			([=width=], [=height=], [=inline size=], [=block size=])
			refers to its post-flexing [=main size=].
	</dl>

	<dl id="cross" export>
		<dt class='axis'>cross axis
		<dt class='axis'>cross dimension
		<dd>
			The axis perpendicular to the <a>main axis</a> is called the <dfn lt="cross axis|cross-axis">cross axis</dfn>.
			It extends in the <dfn>cross dimension</dfn>.

		<dt class='side'>cross-start
		<dt class='side'>cross-end
		<dd>
			<a>Flex lines</a> are filled with items and placed into the container
			starting on the <dfn>cross-start</dfn> side of the flex container
			and going toward the <dfn>cross-end</dfn> side.

		<dt class='size'>cross size
		<dt class='size'>cross size property
		<dd>
			The <dfn>cross size</dfn> of a [=flex container=] or [=flex item=]
			refers to its [=width=] or [=height=],
			whichever is in the [=cross dimension=].
			Its <dfn>cross size property</dfn>
			is either its 'width' or 'height' property,
			whichever is in the [=cross dimension=].
			Likewise, its <dfn lt="min cross size property">min</dfn> and
			<dfn lt="max cross size property">max cross size properties</dfn>
			are its 'min-width'/'max-width' or 'min-height'/'max-height' properties,
			whichever are in the <a>cross dimension</a>,
			and determine its <dfn lt="min cross size">min</dfn>/<dfn>max cross size</dfn>.
	</dl>

	Additional sizing terminology used in this specification
	is defined in <a href="http://www.w3.org/TR/CSS-SIZING-3/">CSS Intrinsic and Extrinsic Sizing</a>. [[!CSS-SIZING-3]]

	<wpt>
		box-sizing-min-max-sizes-001.html
	</wpt>

<!--
████████  ████  ██████  ████████  ██          ███    ██    ██
██     ██  ██  ██    ██ ██     ██ ██         ██ ██    ██  ██
██     ██  ██  ██       ██     ██ ██        ██   ██    ████
██     ██  ██   ██████  ████████  ██       ██     ██    ██
██     ██  ██        ██ ██        ██       █████████    ██
██     ██  ██  ██    ██ ██        ██       ██     ██    ██
████████  ████  ██████  ██        ████████ ██     ██    ██
-->

<h2 id='flex-containers'>
Flex Containers: the ''flex'' and ''inline-flex'' 'display' values</h2>

	<div class="informative">
		<pre class="propdef partial">
		Name: display
		New values: flex | inline-flex
		</pre>
	</div>

	<wpt>
		inheritance.html
	</wpt>

	<dl dfn-type=value dfn-for=display>
		<dt><dfn>flex</dfn>
		<dd>
			This value causes an element to generate a <a>flex container</a> box
			that is <a>block-level</a> when placed in <a>flow layout</a>.

			<wpt>
				baseline-synthesis-001.html
				baseline-synthesis-002.html
				baseline-synthesis-003.html
				baseline-synthesis-004.html
				baseline-synthesis-vert-lr-line-under.html
				display-flex-001.htm
				dynamic-change-simplified-layout-002.html
				dynamic-change-simplified-layout.html
				fixedpos-video-in-abspos-quirk-crash.html
				flexbox_flex-0-0-0.html
				flexbox_flex-0-0-0-unitless.html
				flexbox_flex-0-0-1-unitless-basis.html
				flexbox_flex-0-0-auto.html
				flexbox_flex-0-0-auto-shrink.html
				flexbox_flex-0-0.html
				flexbox_flex-0-0-N.html
				flexbox_flex-0-0-Npercent.html
				flexbox_flex-0-0-Npercent-shrink.html
				flexbox_flex-0-0-N-shrink.html
				flexbox_flex-0-0-N-unitless-basis.html
				flexbox_flex-0-1-0.html
				flexbox_flex-0-1-0-unitless.html
				flexbox_flex-0-1-1-unitless-basis.html
				flexbox_flex-0-1-auto.html
				flexbox_flex-0-1-auto-shrink.html
				flexbox_flex-0-1.html
				flexbox_flex-0-1-N.html
				flexbox_flex-0-1-Npercent.html
				flexbox_flex-0-1-Npercent-shrink.html
				flexbox_flex-0-1-N-shrink.html
				flexbox_flex-0-1-N-unitless-basis.html
				flexbox_flex-0-auto.html
				flexbox_flex-0-N-0.html
				flexbox_flex-0-N-0-unitless.html
				flexbox_flex-0-N-auto.html
				flexbox_flex-0-N-auto-shrink.html
				flexbox_flex-0-N.html
				flexbox_flex-0-N-N.html
				flexbox_flex-0-N-Npercent.html
				flexbox_flex-0-N-Npercent-shrink.html
				flexbox_flex-0-N-N-shrink.html
				flexbox_flex-1-0-0.html
				flexbox_flex-1-0-0-unitless.html
				flexbox_flex-1-0-auto.html
				flexbox_flex-1-0-auto-shrink.html
				flexbox_flex-1-0.html
				flexbox_flex-1-0-N.html
				flexbox_flex-1-0-Npercent.html
				flexbox_flex-1-0-Npercent-shrink.html
				flexbox_flex-1-0-N-shrink.html
				flexbox_flex-1-1-0.html
				flexbox_flex-1-1-0-unitless.html
				flexbox_flex-1-1-auto.html
				flexbox_flex-1-1-auto-shrink.html
				flexbox_flex-1-1.html
				flexbox_flex-1-1-N.html
				flexbox_flex-1-1-Npercent.html
				flexbox_flex-1-1-Npercent-shrink.html
				flexbox_flex-1-1-N-shrink.html
				flexbox_flex-1-N-0.html
				flexbox_flex-1-N-0-unitless.html
				flexbox_flex-1-N-auto.html
				flexbox_flex-1-N-auto-shrink.html
				flexbox_flex-1-N.html
				flexbox_flex-1-N-N.html
				flexbox_flex-1-N-Npercent.html
				flexbox_flex-1-N-Npercent-shrink.html
				flexbox_flex-1-N-N-shrink.html
				flexbox_flex-N-0-0.html
				flexbox_flex-N-0-0-unitless.html
				flexbox_flex-N-0-auto.html
				flexbox_flex-N-0-auto-shrink.html
				flexbox_flex-N-0.html
				flexbox_flex-N-0-N.html
				flexbox_flex-N-0-Npercent.html
				flexbox_flex-N-0-Npercent-shrink.html
				flexbox_flex-N-0-N-shrink.html
				flexbox_flex-N-1-0.html
				flexbox_flex-N-1-0-unitless.html
				flexbox_flex-N-1-auto.html
				flexbox_flex-N-1-auto-shrink.html
				flexbox_flex-N-1.html
				flexbox_flex-N-1-N.html
				flexbox_flex-N-1-Npercent.html
				flexbox_flex-N-1-Npercent-shrink.html
				flexbox_flex-N-1-N-shrink.html
				flexbox_flex-N-N-0.html
				flexbox_flex-N-N-0-unitless.html
				flexbox_flex-N-N-auto.html
				flexbox_flex-N-N-auto-shrink.html
				flexbox_flex-N-N.html
				flexbox_flex-N-N-N.html
				flexbox_flex-N-N-Npercent.html
				flexbox_flex-N-N-Npercent-shrink.html
				flexbox_flex-N-N-N-shrink.html
				flexbox_flex-formatting-interop.html
				flexbox_generated-flex.html
				flexbox_generated.html
				flexbox_generated-nested-flex.html
				flexbox-iframe-intrinsic-size-001.html
				flexbox_item-bottom-float.html
				flexbox_item-clear.html
				flexbox_item-float.html
				flexbox_item-top-float.html
				flexbox_item-vertical-align.html
				flexbox_block.html
				flexbox_box-clear.html
				flexbox_display.html
				flexbox_fbfc2.html
				flexbox_fbfc.html
				flexbox_nested-flex.html
				flexbox-root-node-001a.html
				flexbox-root-node-001b.html
				flexbox_stf-fixpos.html
				flexbox_stf-float.html
				flexbox_stf-inline-block.html
				flexbox_stf-table-caption.html
				flexbox_stf-table-cell.html
				flexbox_stf-table.html
				flexbox_stf-table-row-group.html
				flexbox_stf-table-row.html
				flexbox_stf-table-singleline-2.html
				flexbox_stf-table-singleline.html
				flexbox_table-fixed-layout.html
				flexbox-with-multi-column-property.html
				getcomputedstyle/flexbox_computedstyle_display.html
				grid-flex-item-001.html
				grid-flex-item-002.html
				grid-flex-item-003.html
				grid-flex-item-004.html
				grid-flex-item-005.html
				grid-flex-item-006.html
				grid-flex-item-007.html
				interactive/flexbox_interactive_flex-transitions.html
				interactive/flexbox_interactive_order-transitions-2.html
				interactive/flexbox_interactive_order-transitions.html
				nested-flex-image-loading-invalidates-intrinsic-sizes.html
				percentage-margins-001.html
				stretch-after-sibling-size-change.html
				stretched-child-in-nested-flexbox-001.html
				stretched-child-in-nested-flexbox-002.html
				stretched-child-in-nested-flexbox-003.html
				stretched-child-shrink-on-relayout.html
				stretch-flex-item-checkbox-input.html
				stretch-flex-item-radio-input.html
				stretching-orthogonal-flows.html
				table-with-percent-intrinsic-width.html
			</wpt>

		<dt><dfn>inline-flex</dfn>
		<dd>
			This value causes an element to generate a <a>flex container</a> box
			that is <a>inline-level</a> when placed in <a>flow layout</a>.

			<wpt>
				flexbox_inline.html
				flex-inline.html
				flexbox_inline-float.html
				inline-flexbox-absurd-block-size-crash.html
				inline-flexbox-wrap-vertically-width-calculation.html
				inline-flex-editing-crash.html
				inline-flex-editing-with-updating-text-crash.html
				inline-flex-frameset-main-axis-crash.html
				inline-flex.html
				inline-flex-min-content-height.html
				getcomputedstyle/flexbox_computedstyle_display-inline.html
				intrinsic-width-orthogonal-writing-mode.html
			</wpt>
	</dl>

	A <a>flex container</a> establishes a new <dfn export>flex formatting context</dfn> for its contents.
	This is the same as establishing a block formatting context,
	except that flex layout is used instead of block layout.
	For example, floats do not intrude into the flex container,
	and the flex container's margins do not collapse with the margins of its contents.
	<a>Flex containers</a> form a containing block for their contents
	<a href="https://www.w3.org/TR/CSS2/visudet.html#containing-block-details">exactly like block containers do</a>. [[!CSS2]]
	The 'overflow' property applies to <a>flex containers</a>.

	<wpt>
		flexbox-overflow-horiz-001.html
		flexbox-overflow-horiz-002.html
		flexbox-overflow-horiz-003.html
		flexbox-overflow-horiz-004.html
		flexbox-overflow-horiz-005.html
		flexbox-overflow-padding-001.html
		flexbox-overflow-padding-002.html
		flexbox-overflow-vert-001.html
		flexbox-overflow-vert-002.html
		flexbox-overflow-vert-003.html
		flexbox-overflow-vert-004.html
		flexbox-overflow-vert-005.html
		flexbox_rowspan-overflow-automatic.html
		flexbox_rowspan-overflow.html
		flexbox-safe-overflow-position-001.html
		flexbox-safe-overflow-position-002.html
		flexbox-safe-overflow-position-003.html
		flexbox-safe-overflow-position-004.html
		flexbox-safe-overflow-position-005.html
		flexbox-safe-overflow-position-006.html
		flexbox_width-overflow.html
		min-size-auto-overflow-clip.html
		negative-overflow-002.html
		negative-overflow-003.html
		negative-overflow-004-no-padding.html
		negative-overflow.html
		overflow-area-001.html
		overflow-area-002.html
		overflow-area-003.html
		overflow-auto-001.html
		overflow-auto-002.html
		overflow-auto-003.html
		overflow-auto-004.html
		overflow-auto-005.html
		overflow-auto-006.html
		overflow-auto-007.html
		overflow-auto-008.html
		overflow-top-left.html
		padding-overflow.html
		select-as-flex-item-child-with-overflow.html
		select-as-flex-item-with-overflow.html
		text-overflow-on-flexbox-001.html
		synthesize-vrl-baseline.html
	</wpt>

	Flex containers are not block containers,
	and so some properties that were designed with the assumption of block layout don't apply in the context of flex layout.
	In particular:

		* 'float' and 'clear' do not create floating or clearance of <a>flex item</a>,
			and do not take it <a>out-of-flow</a>.
		* 'vertical-align' has no effect on a flex item.
		* the ''::first-line'' and ''::first-letter'' pseudo-elements do not apply to <a>flex containers</a>,
			and <a>flex containers</a> do not contribute a <a>first formatted line</a> or <a>first letter</a>
			to their ancestors.

			<!--
			Issue: When the Pseudo-Elements spec exists,
			align this language with whatever algo we define for figuring out where to search for first-line/letter content.
			-->

	<wpt>
		align-content-wrap-004.html
		align-items-baseline-column-vert-lr-table-item.html
		align-items-baseline-vert-lr-column-horz-table-item.html
		align-items-baseline-vert-rl-column-horz-table-item.html
		flexbox_box-clear.html
		flexbox_first-letter.html
		flexbox_first-line.html
		flexbox-ignores-first-letter.html
		flexbox_item-vertical-align.html
		flexbox-with-pseudo-elements-001.html
		flexbox-with-pseudo-elements-002.html
		flexbox-with-pseudo-elements-003.html
		flexible-box-float.html
		flex-item-vertical-align.html
		flex-vertical-align-effect.html
		hittest-before-pseudo.html
	</wpt>

	If an element's specified 'display' is ''inline-flex'',
	then its 'display' property computes to ''flex''
	in certain circumstances:
	the table in <a href="https://www.w3.org/TR/CSS2/visuren.html#dis-pos-flo">CSS 2.1 Section 9.7</a>
	is amended to contain an additional row,
	with ''inline-flex'' in the "Specified Value" column
	and ''flex'' in the "Computed Value" column.

<!--
████████ ██       ████████ ██     ██       ████ ████████ ████████ ██     ██  ██████
██       ██       ██        ██   ██         ██     ██    ██       ███   ███ ██    ██
██       ██       ██         ██ ██          ██     ██    ██       ████ ████ ██
██████   ██       ██████      ███           ██     ██    ██████   ██ ███ ██  ██████
██       ██       ██         ██ ██          ██     ██    ██       ██     ██       ██
██       ██       ██        ██   ██         ██     ██    ██       ██     ██ ██    ██
██       ████████ ████████ ██     ██       ████    ██    ████████ ██     ██  ██████
-->

<h2 id='flex-items'>
Flex Items</h2>

	Loosely speaking, the <a>flex items</a> of a <a>flex container</a>
	are boxes representing its <a>in-flow</a> contents.

	Each <a>in-flow</a> child of a <a>flex container</a>
	becomes a <a>flex item</a>,
	and each child <a>text sequence</a>
	is wrapped in an <a>anonymous</a> <a>block container</a> <a>flex item</a>.
	However, if the entire <a>text sequences</a> contains only
	[=document white space characters=]
	(i.e. characters that can be affected by the 'white-space' property)
	it is instead not rendered (just as if its <a>text nodes</a> were ''display:none'').

	<wpt>
		anonymous-block.html
		anonymous-flex-item-001.html
		anonymous-flex-item-002.html
		anonymous-flex-item-003.html
		anonymous-flex-item-004.html
		anonymous-flex-item-005.html
		anonymous-flex-item-006.html
		anonymous-flex-item-document-white-space-crash.html
		anonymous-flex-item-restyle.html
		canvas-dynamic-change-001.html
		column-flex-child-with-max-width.html
		flexbox-whitespace-handling-001a.xhtml
		flexbox-whitespace-handling-001b.xhtml
		flexbox-whitespace-handling-002.xhtml
		hittest-anonymous-box.html
		percentage-descendant-of-anonymous-flex-item.html
		percentage-size-subitems-001.html
		whitespace-in-flexitem-001.html
	</wpt>

	<div class="example">
		<p>Examples of flex items:
		<pre class="lang-markup">
		&lt;div style="display:flex">

		    &lt;!-- flex item: block child -->
		    &lt;div id="item1">block&lt;/div>

		    &lt;!-- flex item: floated element; floating is ignored -->
		    &lt;div id="item2" style="float: left;">float&lt;/div>

		    &lt;!-- flex item: anonymous block box around inline content -->
		    anonymous item 3

		    &lt;!-- flex item: inline child -->
		    &lt;span>
		        item 4
		        &lt;!-- flex items do not <a href="https://www.w3.org/TR/CSS2/visuren.html#anonymous-block-level">split</a> around blocks -->
		        &lt;q style="display: block" id=not-an-item>item 4&lt;/q>
		        item 4
		    &lt;/span>
		&lt;/div>
		</pre>

		<figure>
			<figcaption>Flex items determined from above code block</figcaption>
			<a href="examples/flex-item-determination.html">
				<object type="image/png" data="images/flex-item-determination.png">
					<ol>
						<li>Flex item containing <samp>block</samp>.
						<li>Flex item containing <samp>float</samp>.
						<li>(Anonymous, unstyleable) flex item containing <samp>anonymous item 3</samp>.
						<li>Flex item containing three blocks in succession:
							<ul>
								<li>Anonymous block containing <samp>item 4</samp>.
								<li><code>&lt;q></code> element block containing <samp>item 4</samp>.
								<li>Anonymous block containing <samp>item 4</samp>.
							</ul>
					</ol>
				</object>
			</a>
		</figure>

		Note that the inter-element white space disappears:
		it does not become its own flex item,
		even though the inter-element text <em>does</em> get wrapped in an anonymous flex item.

		Note also that the anonymous item's box is unstyleable,
		since there is no element to assign style rules to.
		Its contents will however inherit styles (such as font settings) from the flex container.
	</div>

	A <a>flex item</a> [=establishes an independent formatting context=] for its contents.
	However, flex items themselves are <dfn export>flex-level</dfn> boxes, not block-level boxes:
	they participate in their container's flex formatting context,
	not in a block formatting context.

	<hr>

	Note: Authors reading this spec may want to
	<a href="#item-margins">skip past the following box-generation and static position details</a>.

	If the [=computed value|computed=] 'display' value of an element's nearest ancestor element
	(skipping ''display:contents'' ancestors)
	is ''flex'' or ''inline-flex'',
	the element's own 'display' value is [=blockified=].
	(See <a href="https://www.w3.org/TR/CSS2/visuren.html#dis-pos-flo">CSS2.1&sect;9.7</a> [[!CSS2]]
	and [[css-display-3#transformations]]
	for details on this type of 'display' value conversion.)

	Note: Blockification still occurs even when the ''flex'' or ''inline-flex'' element does not end up generating a [=flex container=] box,
	e.g. when it is [=replaced element|replaced=]
	or in a ''display: none'' subtree.

	Note: Some values of 'display' normally trigger the creation of anonymous boxes around the original box.
	If such a box is a <a>flex item</a>,
	it is blockified first,
	and so anonymous box creation will not happen.
	For example, two contiguous <a>flex items</a> with ''display: table-cell''
	will become two separate ''display: block'' <a>flex items</a>,
	instead of being wrapped into a single anonymous table.

	In the case of flex items with ''display: table'',
	the table wrapper box becomes the <a>flex item</a>,
	so the 'align-self' property applies to it.
	The contents of any caption boxes contribute to the calculation of
	the table wrapper box's min-content and max-content sizes.
	However, like 'width' and 'height', the 'flex' longhands apply to the table box as follows:
	the <a>flex item</a>’s final size is calculated
	by performing layout as if the distance between
	the table wrapper box's edges and the table box's content edges
	were all part of the table box's border+padding area,
	and the table box were the <a>flex item</a>.

	<wpt>
		flexbox-table-fixup-001.xhtml
	</wpt>

<!--
   ███    ████████   ██████  ████████   ███████   ██████
  ██ ██   ██     ██ ██    ██ ██     ██ ██     ██ ██    ██
 ██   ██  ██     ██ ██       ██     ██ ██     ██ ██
██     ██ ████████   ██████  ████████  ██     ██  ██████
█████████ ██     ██       ██ ██        ██     ██       ██
██     ██ ██     ██ ██    ██ ██        ██     ██ ██    ██
██     ██ ████████   ██████  ██         ███████   ██████
-->

<h3 id='abspos-items'>
Absolutely-Positioned Flex Children</h3>

	As it is <a>out-of-flow</a>,
	an absolutely-positioned child of a <a>flex container</a> does not participate in flex layout.

	The [=cross-axis=] edges of the [=static-position rectangle=]
	of an absolutely-positioned child of a <a>flex container</a>
	are the [=content edges=] of the [=flex container=].
	The [=main-axis=] edges of the [=static-position rectangle=]
	are where the [=margin edges=] of the child would be positioned
	if it were the sole <a>flex item</a> in the <a>flex container</a>,
	assuming both the child and the flex container
	were fixed-size boxes of their used size.
	(For this purpose,
	the child's ''margin/auto'' margins are treated as zero.)

	<wpt>
		abspos/abspos-autopos-htb-ltr.html
		abspos/abspos-autopos-htb-rtl.html
		abspos/abspos-autopos-vlr-ltr.html
		abspos/abspos-autopos-vlr-rtl.html
		abspos/abspos-autopos-vrl-ltr.html
		abspos/abspos-autopos-vrl-rtl.html
		abspos/dynamic-align-self-001.html
		abspos/flex-abspos-staticpos-align-self-safe-002.html
		abspos/flex-abspos-staticpos-align-self-safe-003.html
		abspos/abspos-descendent-001.html
		abspos/flex-abspos-staticpos-align-content-001.html
		abspos/flex-abspos-staticpos-align-self-001.html
		abspos/flex-abspos-staticpos-align-self-002.html
		abspos/flex-abspos-staticpos-align-self-003.html
		abspos/flex-abspos-staticpos-align-self-004.html
		abspos/flex-abspos-staticpos-align-self-005.html
		abspos/flex-abspos-staticpos-align-self-006.html
		abspos/flex-abspos-staticpos-align-self-007.html
		abspos/flex-abspos-staticpos-align-self-008.html
		abspos/flex-abspos-staticpos-align-self-rtl-001.html
		abspos/flex-abspos-staticpos-align-self-rtl-002.html
		abspos/flex-abspos-staticpos-align-self-rtl-003.html
		abspos/flex-abspos-staticpos-align-self-rtl-004.html
		abspos/flex-abspos-staticpos-align-self-safe-001.html
		abspos/flex-abspos-staticpos-align-self-vertWM-001.html
		abspos/flex-abspos-staticpos-align-self-vertWM-002.html
		abspos/flex-abspos-staticpos-align-self-vertWM-003.html
		abspos/flex-abspos-staticpos-align-self-vertWM-004.html
		abspos/flex-abspos-staticpos-fallback-justify-content-001.html
		abspos/flex-abspos-staticpos-justify-content-001.html
		abspos/flex-abspos-staticpos-justify-content-002.html
		abspos/flex-abspos-staticpos-justify-content-003.html
		abspos/flex-abspos-staticpos-justify-content-004.html
		abspos/flex-abspos-staticpos-justify-content-005.html
		abspos/flex-abspos-staticpos-justify-content-006.html
		abspos/flex-abspos-staticpos-justify-content-007.html
		abspos/flex-abspos-staticpos-justify-content-008.html
		abspos/flex-abspos-staticpos-justify-content-rtl-001.html
		abspos/flex-abspos-staticpos-justify-content-rtl-002.html
		abspos/flex-abspos-staticpos-justify-content-vertWM-001.html
		abspos/flex-abspos-staticpos-justify-content-vertWM-002.html
		abspos/flex-abspos-staticpos-justify-self-001.html
		abspos/flex-abspos-staticpos-margin-001.html
		abspos/flex-abspos-staticpos-margin-002.html
		abspos/flex-abspos-staticpos-margin-003.html
		abspos/flexbox_absolute-atomic.html
		abspos/flexbox-abspos-child-001a.html
		abspos/flexbox-abspos-child-001b.html
		abspos/flexbox-abspos-child-002.html
		abspos/flexbox_inline-abspos.html
		abspos/position-absolute-001.html
		abspos/position-absolute-002.html
		abspos/position-absolute-003.html
		abspos/position-absolute-004.html
		abspos/position-absolute-005.html
		abspos/position-absolute-006.html
		abspos/position-absolute-007.html
		abspos/position-absolute-008.html
		abspos/position-absolute-009.html
		abspos/position-absolute-010.html
		abspos/position-absolute-011.html
		abspos/position-absolute-012.html
		abspos/position-absolute-013.html
		abspos/position-absolute-014.html
		abspos/position-absolute-015.html
		abspos/position-absolute-containing-block-001.html
		abspos/position-absolute-containing-block-002.html
		alignment/flex-content-alignment-with-abspos-001.html
		dynamic-grid-flex-abspos.html
		flexbox_stf-abspos.html
		flex-item-position-relative-001.html
	</wpt>

	<div class='example'>
		The effect of this is that if you set, for example,
		''align-self: center;'' on an absolutely-positioned child of a <a>flex container</a>,
		auto offsets on the child will center it in the <a>flex container's</a> <a>cross axis</a>.
	</div>

<h3 id='item-margins'>
Flex Item Margins and Paddings</h3>

	The margins of adjacent <a>flex items</a> do not
	<a href="https://www.w3.org/TR/CSS2/box.html#collapsing-margins">collapse</a>.

	Percentage margins and paddings on <a>flex items</a>,
	like those on <a>block boxes</a>,
	are resolved against the <a>inline size</a> of their <a>containing block</a>,
	e.g. left/right/top/bottom percentages
	all resolve against their <a>containing block</a>’s <em>width</em>
	in horizontal <a>writing modes</a>.

	Auto margins expand to absorb extra space in the corresponding dimension.
	They can be used for alignment,
	or to push adjacent flex items apart.
	See <a href="#auto-margins">Aligning with <span class=css>auto</span> margins</a>.

	<wpt>
		empty-flex-box-and-margin-collapsing.html
		flex-container-margin.html
		flexitem-no-margin-collapsing.html
		flex-margin-no-collapse.html
		negative-margins-001.html
	</wpt>

<h3 id='painting'>
Flex Item Z-Ordering</h3>

	<a>Flex items</a> paint exactly the same as inline blocks [[!CSS2]],
	except that 'order'-modified document order is used in place of raw document order,
	and 'z-index'
	values other than ''z-index/auto'' create a stacking context
	even if 'position' is ''static''
	(behaving exactly as if 'position' were ''relative'').

	Note: Descendants that are positioned outside a flex item still participate
	in any stacking context established by the flex item.

	<wpt>
		flexbox-paint-ordering-001.xhtml
		flexbox-paint-ordering-002.xhtml
		flexbox-paint-ordering-003.html
		flex-item-z-ordering-001.html
		flex-item-z-ordering-002.html
		flexbox-items-as-stacking-contexts-001.xhtml
		flexbox-items-as-stacking-contexts-002.html
		flexbox-items-as-stacking-contexts-003.html
		hittest-overlapping-margin.html
		hittest-overlapping-order.html
		hittest-overlapping-relative.html
	</wpt>

<!--
 ██████   ███████  ██       ██          ███    ████████   ██████  ████████ ████████
██    ██ ██     ██ ██       ██         ██ ██   ██     ██ ██    ██ ██       ██     ██
██       ██     ██ ██       ██        ██   ██  ██     ██ ██       ██       ██     ██
██       ██     ██ ██       ██       ██     ██ ████████   ██████  ██████   ██     ██
██       ██     ██ ██       ██       █████████ ██              ██ ██       ██     ██
██    ██ ██     ██ ██       ██       ██     ██ ██        ██    ██ ██       ██     ██
 ██████   ███████  ████████ ████████ ██     ██ ██         ██████  ████████ ████████
-->

<h3 id='visibility-collapse'>
Collapsed Items</h3>

	Specifying ''visibility:collapse'' on a flex item
	causes it to become a <dfn export lt="collapsed flex item" local-lt="collapsed">collapsed flex item</dfn>,
	producing an effect similar to ''visibility:collapse'' on a table-row or table-column:
	the [=collapsed flex item=] is removed from rendering entirely,
	but leaves behind a "strut" that keeps the flex line's cross-size stable.
	Thus, if a flex container has only one flex line,
	dynamically collapsing or uncollapsing items
	may change the <a>flex container</a>'s <a>main size</a>, but
	is guaranteed to have no effect on its <a>cross size</a>
	and won't cause the rest of the page's layout to "wobble".
	Flex line wrapping <em>is</em> re-done after collapsing, however,
	so the cross size of a flex container with multiple lines might or might not change.

	Though [=collapsed flex items=] aren't rendered,
	they do appear in the <a href="https://www.w3.org/TR/CSS2/intro.html#formatting-structure">formatting structure</a>.
	Therefore, unlike on ''display:none'' items [[!CSS2]],
	effects that depend on a box appearing in the formatting structure
	(like incrementing counters or running animations and transitions)
	still operate on collapsed items.

	<wpt>
		flexbox_visibility-collapse.html
		flexbox_visibility-collapse-line-wrapping.html
	</wpt>

	<div class="example">
		In the following example,
		a sidebar is sized to fit its content.
		''visibility: collapse'' is used to dynamically hide parts of a navigation sidebar
		without affecting its width, even though the widest item (&ldquo;Architecture&rdquo;)
		is in a collapsed section.

		<figure>
			<figcaption>Sample live rendering for example code below</figcaption>
			<div id="visibility-collapse-example">
			<!-- No, don't look at this source code, look at the other source code. -->
			  <nav>
			    <ul>
			      <li id="nav-about"><a href="#nav-about">About</a>
			        <ul>
			          <li><a href="#">History</a>
			          <li><a href="#">Mission</a>
			          <li><a href="#">People</a>
			        </ul>
			      <li id="nav-projects"><a href="#nav-projects">Projects</a>
			        <ul>
			          <li><a href="#">Art</a>
			          <li><a href="#">Architecture</a>
			          <li><a href="#">Music</a>
			        </ul>
			      <li id="nav-interact"><a href="#nav-interact">Interact</a>
			        <ul>
			          <li><a href="#">Blog</a>
			          <li><a href="#">Forums</a>
			          <!-- li><a href="#">Events</a> -->
			        </ul>
			    </ul>
			  </nav>
			  <article>
			    Hover over the menu to the left:
			    each section expands to show its sub-items.
			    In order to keep the sidebar width (and this main area width) stable,
			    ''visibility: collapse'' is used instead of ''display: none''.
			    This results in a sidebar that is always wide enough for the word “Architecture”,
			    even though it is not always visible.
			  </article>
			</div>
		</figure>

		<pre class="lang-css">
			  @media (min-width: 60em) {
			    /* <a href="https://www.w3.org/TR/css3-mediaqueries/#width">two column layout only when enough room</a> (relative to default text size) */
			    div { display: flex; }
			    #main {
			      flex: 1;         /* <a href="#flexibility">Main takes up all remaining space</a> */
			      order: 1;        /* Place it after (to the right of) the navigation */
			      min-width: 12em; /* Optimize main content area sizing */
			    }
			  }
			  /* menu items use flex layout so that visibility:collapse will work */
			  nav > ul > li {
			    display: flex;
			    flex-flow: column;
			  }
			  /* dynamically collapse submenus when not targeted */
			  nav > ul > li:not(:target):not(:hover) > ul {
			    visibility: collapse;
			  }
		</pre>
		<pre class="lang-markup">
			&lt;div>
			  &lt;article id="main">
			    Interesting Stuff to Read
			  &lt;/article>
			  &lt;nav>
			    &lt;ul>
			      &lt;li id="nav-about">&lt;a href="#nav-about">About&lt;/a>
			        &hellip;
			      &lt;li id="nav-projects">&lt;a href="#nav-projects">Projects&lt;/a>
			        &lt;ul>
			          &lt;li>&lt;a href="&hellip;">Art&lt;/a>
			          &lt;li>&lt;a href="&hellip;">Architecture&lt;/a>
			          &lt;li>&lt;a href="&hellip;">Music&lt;/a>
			        &lt;/ul>
			      &lt;li id="nav-interact">&lt;a href="#nav-interact">Interact&lt;/a>
			        &hellip;
			    &lt;/ul>
			  &lt;/nav>
			&lt;/div>
			&lt;footer>
			&hellip;
		</pre>
	</div>

	To compute the size of the strut, flex layout is first performed with all items uncollapsed,
	and then re-run with each [=collapsed flex item=] replaced by a strut that maintains
	the original [=cross size=] of the item's original line.
	See the <a href="#layout-algorithm">Flex Layout Algorithm</a>
	for the normative definition of how ''visibility:collapse''
	interacts with flex layout.

	Note: Using ''visibility:collapse'' on any flex items
	will cause the flex layout algorithm to repeat partway through,
	re-running the most expensive steps.
	It's recommended that authors continue to use ''display:none'' to hide items
	if the items will not be dynamically collapsed and uncollapsed,
	as that is more efficient for the layout engine.
	(Since only part of the steps need to be repeated when 'visibility' is changed,
	however, 'visibility: collapse' is still recommended for dynamic cases.)

<!--
██     ██ ████ ██    ██
███   ███  ██  ███   ██          ██   ██
████ ████  ██  ████  ██           ██ ██
██ ███ ██  ██  ██ ██ ██ ███████ █████████
██     ██  ██  ██  ████           ██ ██
██     ██  ██  ██   ███          ██   ██
██     ██ ████ ██    ██
-->

<h3 id="min-size-auto">
Automatic Minimum Size of Flex Items</h3>

	Note: The ''min-width/auto'' keyword,
	representing an <a>automatic minimum size</a>,
	is the new initial value of the 'min-width' and 'min-height' properties.
	The keyword was previously defined in this specification,
	but is now defined in the [[!CSS-SIZING-3|CSS Sizing]] module.

	To provide a more reasonable default <a>minimum size</a> for <a>flex items</a>,
	the used value of a <a>main axis</a> <a>automatic minimum size</a>
	on a <a>flex item</a> whose [=computed value|computed=] 'overflow' value is [=non-scrollable overflow value|non-scrollable=]
	is its [=content-based minimum size=];
	for [=block-axis scroll container|main-axis scroll containers=] the <a>automatic minimum size</a> is zero, as usual.

	The <dfn>content-based minimum size</dfn> of a [=flex item=]
	differs depending on whether the [=flex item=] is [=replaced element|replaced=] or not:

	: For [=replaced elements=]
	::
		Use the smaller of the [=content size suggestion=]
		and the [=transferred size suggestion=]
		(if one exists),
		capped by the [=specified size suggestion=]
		(if one exists).

	: For [=non-replaced elements=]
	::
		Use the larger of the [=content size suggestion=]
		and the [=transferred size suggestion=]
		(if one exists),
		capped by the [=specified size suggestion=]
		(if one exists).

	In either case,
	the size is clamped by the [=maximum size|maximum=] [=main size=]
	if it's <a>definite</a>.

	<wpt>
		image-items-flake-001.html
	</wpt>

<!-- This differs from Grid's definition
(which just consults the first of specified,transferred,content that exists)
because we explicitly want to let flex items shrink to their min-content size.
Grid doesn't have similarly meaningful shrinkability, so it doesn't need to care. -->

	The <a>content size suggestion</a>, <a>specified size suggestion</a>, and <a>transferred size suggestion</a>
	used in this calculation account for the relevant min/max/preferred size properties
	so that the <a>content-based minimum size</a> does not interfere with any author-provided constraints,
	and are defined below:

	<dl>
		<dt><dfn>specified size suggestion</dfn>
		<dd>
			If the item’s [=preferred size|preferred=] [=main size=] is <a>definite</a> and not [=automatic size|automatic=],
			then the <a>specified size suggestion</a> is that size.
			It is otherwise undefined.

		<dt><dfn>transferred size suggestion</dfn>
		<dd>
			If the item has a [=preferred aspect ratio=]
			and its [=preferred size|preferred=] [=cross size=] is <a>definite</a>,
			then the <a>transferred size suggestion</a> is that size
			(clamped by its [=minimum size|minimum=] and [=maximum size|maximum=] [=cross sizes=] if they are <a>definite</a>),
			converted through the aspect ratio.
			It is otherwise undefined.

		<dt><dfn>content size suggestion</dfn>
		<dd>
			The <a>content size suggestion</a> is the <a>min-content size</a> in the <a>main axis</a>,
			clamped, if it has a [=preferred aspect ratio=],
			by any <a>definite</a> [=minimum size|minimum=] and [=maximum size|maximum=] [=cross sizes=] converted through the aspect ratio.
	</dl>

	<wpt>
		content-height-with-scrollbars.html
		fieldset-as-item-dynamic.html
		fieldset-as-item-overflow.html
		flex-aspect-ratio-img-column-001.html
		flex-aspect-ratio-img-column-002.html
		flex-aspect-ratio-img-column-003.html
		flex-aspect-ratio-img-column-004.html
		flex-aspect-ratio-img-column-005.html
		flex-aspect-ratio-img-column-006.html
		flex-aspect-ratio-img-column-007.html
		flex-aspect-ratio-img-column-008.html
		flex-aspect-ratio-img-column-009.html
		flex-aspect-ratio-img-column-010.html
		flex-aspect-ratio-img-column-011.html
		flex-aspect-ratio-img-column-012.html
		flex-aspect-ratio-img-column-013.html
		flex-aspect-ratio-img-column-014.html
		flex-aspect-ratio-img-column-015.html
		flex-aspect-ratio-img-column-016.html
		flex-aspect-ratio-img-column-017.html
		flex-aspect-ratio-img-column-018.html
		flex-aspect-ratio-img-row-001.html
		flex-aspect-ratio-img-row-002.html
		flex-aspect-ratio-img-row-003.html
		flex-aspect-ratio-img-row-004.html
		flex-aspect-ratio-img-row-005.html
		flex-aspect-ratio-img-row-006.html
		flex-aspect-ratio-img-row-007.html
		flex-aspect-ratio-img-row-008.html
		flex-aspect-ratio-img-row-009.html
		flex-aspect-ratio-img-row-010.html
		flex-aspect-ratio-img-row-011.html
		flex-aspect-ratio-img-row-012.html
		flex-aspect-ratio-img-row-013.html
		flex-aspect-ratio-img-row-014.html
		flex-aspect-ratio-img-row-015.html
		flex-aspect-ratio-img-row-016.html
		flex-aspect-ratio-img-row-017.html
		flex-aspect-ratio-img-vert-lr.html
		flexbox-definite-cross-size-constrained-percentage.html
		flexbox-min-height-auto-001.html
		flexbox-min-height-auto-002a.html
		flexbox-min-height-auto-002b.html
		flexbox-min-height-auto-002c.html
		flexbox-min-height-auto-003.html
		flexbox-min-height-auto-004.html
		flexbox-min-width-auto-001.html
		flexbox-min-width-auto-002a.html
		flexbox-min-width-auto-002b.html
		flexbox-min-width-auto-002c.html
		flexbox-min-width-auto-003.html
		flexbox-min-width-auto-004.html
		flexbox-min-width-auto-005.html
		flexbox-min-width-auto-006.html
		flex-item-compressible-001.html
		flex-item-compressible-002.html
		flexitem-stretch-image.html
		flexitem-stretch-range.html
		flex-minimum-height-flex-items-001.xht
		flex-minimum-height-flex-items-002.xht
		flex-minimum-height-flex-items-003.xht
		flex-minimum-height-flex-items-004.xht
		flex-minimum-height-flex-items-005.xht
		flex-minimum-height-flex-items-006.xht
		flex-minimum-height-flex-items-007.xht
		flex-minimum-height-flex-items-008.xht
		flex-minimum-height-flex-items-009.html
		flex-minimum-height-flex-items-010.html
		flex-minimum-height-flex-items-011.xht
		flex-minimum-height-flex-items-012.html
		flex-minimum-height-flex-items-013.html
		flex-minimum-height-flex-items-014.html
		flex-minimum-height-flex-items-015.html
		flex-minimum-height-flex-items-016.html
		flex-minimum-height-flex-items-017.html
		flex-minimum-height-flex-items-018.html
		flex-minimum-height-flex-items-019.html
		flex-minimum-height-flex-items-020.html
		flex-minimum-height-flex-items-021.html
		flex-minimum-height-flex-items-022.html
		flex-minimum-height-flex-items-023.html
		flex-minimum-height-flex-items-024.html
		flex-minimum-height-flex-items-025.html
		flex-minimum-height-flex-items-026.html
		flex-minimum-height-flex-items-027.html
		flex-minimum-height-flex-items-028.html
		flex-minimum-height-flex-items-029.html
		flex-minimum-height-flex-items-030.html
		flex-minimum-height-flex-items-031.html
		flex-minimum-size-001.html
		flex-minimum-size-002.html
		flex-minimum-size-003.html
		flex-minimum-width-flex-items-001.xht
		flex-minimum-width-flex-items-002.xht
		flex-minimum-width-flex-items-003.xht
		flex-minimum-width-flex-items-004.xht
		flex-minimum-width-flex-items-005.xht
		flex-minimum-width-flex-items-006.xht
		flex-minimum-width-flex-items-007.xht
		flex-minimum-width-flex-items-008.xht
		flex-minimum-width-flex-items-009.html
		flex-minimum-width-flex-items-010.html
		flex-minimum-width-flex-items-011.html
		flex-minimum-width-flex-items-012.html
		flex-minimum-width-flex-items-013.html
		flex-minimum-width-flex-items-014.html
		flex-minimum-width-flex-items-015.html
		flex-minimum-width-flex-items-016.html
		checkbox-percentage-width-in-flex.html
		getcomputedstyle/flexbox_computedstyle_min-auto-size.html
		getcomputedstyle/flexbox_computedstyle_min-height-auto.html
		getcomputedstyle/flexbox_computedstyle_min-width-auto.html
		select-element-zero-height-001.html
		select-element-zero-height-002.html
	</wpt>

	Note: The [=content-based minimum size=] is a type of [=intrinsic size contribution=],
	and thus the cyclic percentage provisions in [[css-sizing-3#intrinsic-contribution]] apply.

	For the purpose of calculating an intrinsic size of the box
	(e.g. the box’s <a>min-content size</a>),
	a <a>content-based minimum size</a> causes the box’s size in that axis to become indefinite
	(even if e.g. its 'width' property specifies a <a>definite</a> size).
	Note this means that percentages calculated against this size
	will [=behave as auto=].

	For any purpose <em>other than</em> calculating intrinsic sizes,
	a [=content-based minimum size=]
	(unlike an explicit ''min-content''/etc [=minimum size=])
	does not force the box's size to become indefinite.
	However, if a percentage resolved against the box's size <em>before</em> this minimum was applied,
	it must be re-resolved against the new size after it is applied.

	<div class="note" id="min-size-opt">
		Note that while a content-based minimum size is often appropriate,
		and helps prevent content from overlapping or spilling outside its container,
		in some cases it is not:

		In particular, if flex sizing is being used for a major content area of a document,
		it is better to set an explicit font-relative minimum width such as ''min-width: 12em''.
		A content-based minimum width could result in a large table or large image
		stretching the size of the entire content area into an overflow zone,
		and thereby making lines of text gratuitously long and hard to read.

		Note also, when content-based sizing is used on an item with large amounts of content,
		the layout engine must traverse all of this content before finding its minimum size,
		whereas if the author sets an explicit minimum, this is not necessary.
		(For items with small amounts of content, however,
		this traversal is trivial and therefore not a performance concern.)
	</div>

	<wpt>
		aspect-ratio-intrinsic-size-001.html
		aspect-ratio-intrinsic-size-002.html
		aspect-ratio-intrinsic-size-003.html
		aspect-ratio-intrinsic-size-004.html
		aspect-ratio-intrinsic-size-005.html
		aspect-ratio-intrinsic-size-006.html
		aspect-ratio-intrinsic-size-007.html
		aspect-ratio-intrinsic-size-008.html
		aspect-ratio-intrinsic-size-009.html
		aspect-ratio-intrinsic-size-010.html
		aspect-ratio-transferred-max-size.html
		flex-item-content-is-min-width-max-content.html
	</wpt>


<h2 id="flow-order">
Ordering and Orientation</h2>

	The contents of a flex container can be laid out 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 hacks using the 'float' and 'clear' properties.
	This functionality is exposed through the 'flex-direction', 'flex-wrap', and 'order' properties.

	Note: The reordering capabilities of flex layout intentionally affect
	<em>only the visual rendering</em>,
	leaving speech order and navigation based on the source order.
	This allows authors to manipulate the visual presentation
	while leaving the source order intact for non-CSS UAs and for
	linear models such as speech and sequential navigation.
	See [[css-display-3#order-accessibility]]
	and the <a href="#overview">Flex Layout Overview</a> for examples
	that use this dichotomy to improve accessibility.

	Advisement:
	Authors <em>must not</em> use 'order' or the ''*-reverse'' values of 'flex-flow'/'flex-direction'
	as a substitute for correct source ordering,
	as that can ruin the accessibility of the document.

<!--
████████ ██       ████████ ██     ██         ████████  ████ ████████  ████████  ██████  ████████ ████  ███████  ██    ██
██       ██       ██        ██   ██          ██     ██  ██  ██     ██ ██       ██    ██    ██     ██  ██     ██ ███   ██
██       ██       ██         ██ ██           ██     ██  ██  ██     ██ ██       ██          ██     ██  ██     ██ ████  ██
██████   ██       ██████      ███    ███████ ██     ██  ██  ████████  ██████   ██          ██     ██  ██     ██ ██ ██ ██
██       ██       ██         ██ ██           ██     ██  ██  ██   ██   ██       ██          ██     ██  ██     ██ ██  ████
██       ██       ██        ██   ██          ██     ██  ██  ██    ██  ██       ██    ██    ██     ██  ██     ██ ██   ███
██       ████████ ████████ ██     ██         ████████  ████ ██     ██ ████████  ██████     ██    ████  ███████  ██    ██
-->

<h3 id='flex-direction-property'>
Flex Flow Direction: the 'flex-direction' property</h3>

	<pre class='propdef'>
	Name: flex-direction
	Value: row | row-reverse | column | column-reverse
	Initial: row
	Applies to: <a>flex containers</a>
	Inherited: no
	Computed value: specified keyword
	Animation type: discrete
	</pre>

	The 'flex-direction' property specifies how <a>flex items</a> are placed in the flex container,
	by setting the direction of the flex container's <a>main axis</a>.
	This determines the direction in which flex items are laid out.

	<dl dfn-type=value dfn-for=flex-direction>
		<dt><dfn>row</dfn>
		<dd>
			The flex container's <a>main axis</a> has the same orientation as the
			<a>inline axis</a>
			of the current <a>writing mode</a>.
			The <a>main-start</a> and <a>main-end</a> directions are equivalent to the
			<a>inline-start</a> and
			<a>inline-end</a> directions, respectively,
			of the current <a>writing mode</a>.

			<wpt>
				flex-child-percent-basis-resize-1.html
				flexbox-flex-basis-content-001a.html
				flexbox-flex-basis-content-001b.html
				flexbox-flex-direction-row.htm
				flexbox_justifycontent-left-001.html
				flexbox-writing-mode-010.html
				flexbox-writing-mode-011.html
				flexbox-writing-mode-012.html
				flexbox-writing-mode-016.html
				percentage-size.html
			</wpt>

		<dt><dfn>row-reverse</dfn>
		<dd>
			Same as ''row'',
			except the <a>main-start</a> and <a>main-end</a> directions are swapped.

			<wpt>
				flexbox_direction-row-reverse.html
				flexbox-mbp-horiz-001-reverse.xhtml
				flexbox-mbp-horiz-001-rtl-reverse.xhtml
				flex-lines/multi-line-wrap-with-row-reverse.html
				flexbox_justifycontent-right-001.html
				flexbox_justifycontent-start.html
				flexbox_justifycontent-start-rtl.html
			</wpt>

		<dt><dfn>column</dfn>
		<dd>
			The flex container's <a>main axis</a> has the same orientation as the
			<a>block axis</a>
			of the current <a>writing mode</a>.
			The <a>main-start</a> and <a>main-end</a> directions are equivalent to the
			<a>block-start</a> and
			<a>block-end</a> directions, respectively,
			of the current <a>writing mode</a>.

			<wpt>
				columns-height-set-via-top-bottom.html
				dynamic-bsize-change.html
				flexbox_direction-column.html
				flexbox_direction-column-reverse.html
				flexbox_rtl-flow.html
				flex-column-relayout-assert.html
				flex-item-max-height-min-content.html
				flex-item-transferred-sizes-padding-border-sizing.html
				flex-item-transferred-sizes-padding-content-sizing.html
				flex-outer-flexbox-column-recalculate-height-on-resize-001.html
				image-nested-within-definite-column-flexbox.html
				layout-with-inline-svg-001.html
				nested-orthogonal-flexbox-relayout.html
				percentage-max-width-cross-axis.html
				percentage-size.html
			</wpt>

		<dt><dfn>column-reverse</dfn>
		<dd>
			Same as ''column'',
			except the <a>main-start</a> and <a>main-end</a> directions are swapped.

			<wpt>
				column-reverse-gap.html
				flexbox_rtl-direction.html
				flex-lines/multi-line-wrap-with-column-reverse.html
			</wpt>
	</dl>

	Note: The reverse values do not reverse box ordering:
	like 'writing-mode' and 'direction' [[CSS3-WRITING-MODES]],
	they only change the direction of flow.
	Painting order, speech order, and sequential navigation orders
	are not affected.

	Note: Depending on the value of 'justify-content',
	the reverse values of 'flex-direction' can alter the initial scroll position
	on [=flex containers=] that are also [=scroll containers=].
	See [[css-align-3#overflow-scroll-position]].

	<wpt>
		animation/discrete-no-interpolation.html
		change-column-flex-width.html
		column-flex-child-with-max-width.html
		column-flex-child-with-overflow-scroll.html
		cross-axis-scrollbar.html
		dynamic-orthogonal-flex-item.html
		flexbox-writing-mode-001.html
		flexbox-writing-mode-002.html
		flexbox-writing-mode-003.html
		flexbox-writing-mode-004.html
		flexbox-writing-mode-005.html
		flexbox-writing-mode-006.html
		flexbox-writing-mode-007.html
		flexbox-writing-mode-008.html
		flexbox-writing-mode-009.html
		flexbox-writing-mode-010.html
		flexbox-writing-mode-011.html
		flexbox-writing-mode-012.html
		flexbox-writing-mode-013.html
		flexbox-writing-mode-014.html
		flexbox-writing-mode-015.html
		flexbox-writing-mode-016.html
		flexbox-writing-mode-slr.html
		flexbox-writing-mode-slr-row-mix.html
		flexbox-writing-mode-slr-rtl.html
		flexbox-writing-mode-srl.html
		flexbox-writing-mode-srl-row-mix.html
		flexbox-writing-mode-srl-rtl.html
		flexbox_object.html
		flexbox_writing_mode_vertical_lays_out_contents_from_top_to_bottom.html
		getcomputedstyle/flexbox_computedstyle_flex-direction-column.html
		getcomputedstyle/flexbox_computedstyle_flex-direction-column-reverse.html
		getcomputedstyle/flexbox_computedstyle_flex-direction-invalid.html
		getcomputedstyle/flexbox_computedstyle_flex-direction-row.html
		getcomputedstyle/flexbox_computedstyle_flex-direction-row-reverse.html
	</wpt>

<!--
████████ ██       ████████ ██     ██         ██      ██ ████████     ███    ████████
██       ██       ██        ██   ██          ██  ██  ██ ██     ██   ██ ██   ██     ██
██       ██       ██         ██ ██           ██  ██  ██ ██     ██  ██   ██  ██     ██
██████   ██       ██████      ███    ███████ ██  ██  ██ ████████  ██     ██ ████████
██       ██       ██         ██ ██           ██  ██  ██ ██   ██   █████████ ██
██       ██       ██        ██   ██          ██  ██  ██ ██    ██  ██     ██ ██
██       ████████ ████████ ██     ██          ███  ███  ██     ██ ██     ██ ██
-->

<h3 id='flex-wrap-property'>
Flex Line Wrapping: the 'flex-wrap' property</h3>

	<pre class='propdef'>
	Name: flex-wrap
	Value: nowrap | wrap | wrap-reverse
	Initial: nowrap
	Applies to: <a>flex containers</a>
	Inherited: no
	Computed value: specified keyword
	Animation type: discrete
	</pre>

	The 'flex-wrap' property controls whether the flex container is <a>single-line</a> or <a>multi-line</a>,
	and the direction of the <a>cross-axis</a>,
	which determines the direction new lines are stacked in.

	<dl dfn-type=value dfn-for=flex-wrap>
		<dt><dfn>nowrap</dfn>
		<dd>
			The flex container is <a>single-line</a>.

		<dt><dfn>wrap</dfn>
		<dd>
			The flex container is <a>multi-line</a>.

		<dt><dfn>wrap-reverse</dfn>
		<dd>
			Same as ''wrap''.
	</dl>

	For the values that are not ''wrap-reverse'',
	the <a>cross-start</a> direction is equivalent to either
	the <a>inline-start</a> or <a>block-start</a> direction of the current <a>writing mode</a>
	(whichever is in the <a>cross axis</a>)
	and the <a>cross-end</a> direction is the opposite direction of <a>cross-start</a>.
	When 'flex-wrap' is ''wrap-reverse'',
	the <a>cross-start</a> and <a>cross-end</a> directions
	are swapped.

	Note: Depending on the value of 'align-content',
	the ''wrap-reverse'' value of 'flex-wrap' can alter the initial scroll position
	on [=flex containers=] that are also [=scroll containers=].
	See [[css-align-3#overflow-scroll-position]].

	<wpt>
		animation/discrete-no-interpolation.html
		flexbox-flex-wrap-default.htm
		flexbox-flex-wrap-flexing-002.html
		flexbox-flex-wrap-flexing-003.html
		flexbox-flex-wrap-flexing.html
		flexbox-flex-wrap-horiz-001.html
		flexbox-flex-wrap-horiz-002.html
		flexbox-flex-wrap-nowrap.htm
		flexbox-flex-wrap-vert-001.html
		flexbox-flex-wrap-vert-002.html
		flexbox-flex-wrap-wrap.htm
		flexbox-flex-wrap-wrap-reverse.htm
		flexbox_rowspan.html
		flexbox_rtl-flow.html
		flexbox_rtl-flow-reverse.html
		flexbox_rtl-order.html
		flex-box-wrap.html
		flexbox_wrap.html
		flexbox_wrap-long.html
		flexbox_wrap-reverse.html
		flex-lines/multi-line-wrap-reverse-column-reverse.html
		flex-lines/multi-line-wrap-reverse-row-reverse.html
		getcomputedstyle/flexbox_computedstyle_flex-wrap-invalid.html
		getcomputedstyle/flexbox_computedstyle_flex-wrap-nowrap.html
		getcomputedstyle/flexbox_computedstyle_flex-wrap-wrap.html
		getcomputedstyle/flexbox_computedstyle_flex-wrap-wrap-reverse.html
		multiline-min-preferred-width.html
		multiline-reverse-wrap-baseline.html

	</wpt>

<!--
████████ ██       ████████ ██     ██         ████████ ██        ███████  ██      ██
██       ██       ██        ██   ██          ██       ██       ██     ██ ██  ██  ██
██       ██       ██         ██ ██           ██       ██       ██     ██ ██  ██  ██
██████   ██       ██████      ███    ███████ ██████   ██       ██     ██ ██  ██  ██
██       ██       ██         ██ ██           ██       ██       ██     ██ ██  ██  ██
██       ██       ██        ██   ██          ██       ██       ██     ██ ██  ██  ██
██       ████████ ████████ ██     ██         ██       ████████  ███████   ███  ███
-->

<h3 id='flex-flow-property'>
Flex Direction and Wrap: the 'flex-flow' shorthand</h3>

	<pre class='propdef shorthand'>
	Name: flex-flow
	Value: <<'flex-direction'>> || <<'flex-wrap'>>
	</pre>

	<wpt>
		box-sizing-001.html
		button-column-wrap-crash.html
		column-intrinsic-size-aspect-ratio-crash.html
		css-flexbox-row.html
		css-flexbox-row-reverse.html
		css-flexbox-row-reverse-wrap.html
		css-flexbox-row-reverse-wrap-reverse.html
		css-flexbox-row-wrap.html
		css-flexbox-row-wrap-reverse.html
		css-flexbox-test1.html
		flexbox-flex-direction-column.htm
		flexbox-flex-direction-column-percentage-ignored.html
		flexbox-flex-direction-column-reverse.htm
		flexbox-flex-direction-default.htm
		flexbox-flex-direction-row.htm
		flexbox-flex-direction-row-reverse.htm
		flex-direction-column-001-visual.html
		flex-direction-column.html
		flex-direction-column-overlap-001.html
		flex-direction-column-reverse-001-visual.html
		flex-direction-column-reverse-002-visual.html
		flex-direction-column-reverse.html
		flex-direction.html
		flex-direction-modify.html
		flex-direction-row-001-visual.html
		flex-direction-row-002-visual.html
		flex-direction-row-reverse-001-visual.html
		flex-direction-row-reverse-002-visual.html
		flex-direction-row-reverse.html
		flex-direction-row-vertical.html
		flex-direction-with-element-insert.html
		flexbox-flex-flow-001.html
		flexbox-flex-flow-002.html
		flexbox_flow-column-reverse-wrap.html
		flexbox_flow-column-reverse-wrap-reverse.html
		flexbox_flow-column-wrap.html
		flexbox_flow-column-wrap-reverse.html
		flexbox_flow-row-wrap.html
		flexbox_flow-row-wrap-reverse.html
		flex-flow-001.html
		flex-flow-002.html
		flex-flow-003.html
		flex-flow-004.html
		flex-flow-005.html
		flex-flow-006.html
		flex-flow-007.html
		flex-flow-008.html
		flex-flow-009.html
		flex-flow-010.html
		flex-flow-011.html
		flex-flow-012.html
		flex-flow-013.html
		flex-wrap-002.html
		flex-wrap-003.html
		flex-wrap-004.html
		flex-wrap-005.html
		flex-wrap-006.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-column.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-column-nowrap.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-column-reverse.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-column-reverse-nowrap.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-column-reverse-wrap.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-column-wrap.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-column-wrap-reverse.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-nowrap.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-row.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-row-nowrap.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-row-reverse.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-row-reverse-nowrap.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-row-reverse-wrap.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-row-reverse-wrap-reverse.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-row-wrap.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-row-wrap-reverse.html
		getcomputedstyle/flexbox_computedstyle_flex-flow-wrap.html
		multiline-column-max-height.html
		parsing/flex-direction-computed.html
		parsing/flex-direction-invalid.html
		parsing/flex-direction-valid.html
		parsing/flex-flow-computed.html
		parsing/flex-flow-invalid.html
		parsing/flex-flow-shorthand.html
		parsing/flex-flow-valid.html
		parsing/flex-wrap-computed.html
		parsing/flex-wrap-invalid.html
		parsing/flex-wrap-valid.html
	</wpt>

	The 'flex-flow' property is a shorthand for setting the 'flex-direction' and 'flex-wrap' properties,
	which together define the flex container's main and cross axes.

	<div class="example">
		Some examples of valid flows in an English (left-to-right, horizontal writing mode) document:

		<table style="margin: 0 auto; vertical-align: middle; border-spacing: 2em 1em;">
			<tr>
				<td>
					<pre class="lang-css">
					div { flex-flow: row; }
					/* Initial value. Main-axis is inline, no wrapping.
					   (Items will either shrink to fit or overflow.) */
					</pre>
				<td><img src='images/flex-flow1.svg' width=205 height=46 alt>
			<tr>
				<td>
					<pre class="lang-css">
					div { flex-flow: column wrap; }
					/* Main-axis is block-direction (top to bottom)
					   and lines wrap in the inline direction (rightwards). */
					</pre>
				<td><img src='images/flex-flow2.svg' width=89 height=160 alt>
			<tr>
				<td>
					<pre class="lang-css">
					div { flex-flow: row-reverse wrap-reverse; }
					/* Main-axis is the opposite of inline direction
					   (right to left). New lines wrap upwards. */
					</pre>
				<td><img src='images/flex-flow3.svg' width=160 height=89 alt>
		</table>
	</div>

	<div class='note'>
		Note that the 'flex-flow' directions are <a>writing mode</a> sensitive.
		In vertical Japanese, for example,
		a ''row'' flex container lays out its contents from top to bottom,
		as seen in this example:

		<table style="margin: 1em auto; text-align: center;">
			<thead>
				<tr>
					<th>English
					<th>Japanese
			<tbody>
				<tr>
					<td><pre class="lang-css">flex-flow: row wrap;<br>writing-mode: horizontal-tb;</pre>
					<td><pre class="lang-css">flex-flow: row wrap;<br>writing-mode: vertical-rl;</pre>
				<tr>
					<td><img src='images/flex-flow-english.svg' width=160 height=89 alt>
					<td><img src='images/flex-flow-japanese.svg' width=89 height=160 alt>
		</table>
	</div>

<h3 id='order-property' oldids="propdef-order,order-accessibility,order-modified-document-order">
Reordering and Accessibility: the 'order' property</h3>

	<a>Flex items</a> are, by default, displayed and laid out
	in the same order as they appear in the source document,
	which represents their logical ordering.
	This same order is used in rendering to non-visual media
	(such as <a href="https://www.w3.org/TR/css-speech/">speech</a>),
	in the default traversal order of sequential navigation modes
	(such as cycling through links,
	see e.g. <a href="https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex"><code>tabindex</code></a> [[HTML]]),
	and when content is represented in non-CSS UAs.

	The 'order' property can be used to change flex items’ ordering,
	laying them out in [=order-modified document order=] instead,
	in order to make their spatial arrangement on the 2D visual canvas
	differ from their logical order in linear presentations
	such as speech and sequential navigation.
	See [[CSS-DISPLAY-3#order-property]].
	[[!CSS-DISPLAY-3]]

	Note: Since visual perception is two-dimensional and non-linear,
	the desired box order is not always the same logical order
	used by non-visual media and non-CSS UAs.

	Advisement:
	Authors <em>must</em> use 'order' only for visual, not logical, reordering of content.
	Style sheets that use 'order' to perform logical reordering are non-conforming.

	<div class='example'>
		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.
		'order' makes this trivial.
		For example, take the following sketch of a page's code and desired layout:

		<div class='code-and-figure'>
			<div>
				<pre class="lang-markup">
					&lt;!DOCTYPE html>
					&lt;header>...&lt;/header>
					&lt;main>
					   &lt;article>...&lt;/article>
					   &lt;nav>...&lt;/nav>
					   &lt;aside>...&lt;/aside>
					&lt;/main>
					&lt;footer>...&lt;/footer>
				</pre>
			</div>
			<div><img src="images/flex-order-page.svg" width=400 height=360 alt="In this page the header is at the top and the footer at the bottom, but the article is in the center, flanked by the nav on the right and the aside on the left."></div>
		</div>

		This layout can be easily achieved with flex layout:

		<pre class="lang-css">
			main { display: flex; }
			main > article { order: 2; min-width: 12em; flex:1; }
			main > nav     { order: 1; width: 200px; }
			main > aside   { order: 3; width: 200px; }
		</pre>

		As an added bonus,
		the columns will all be <a value for=align-self lt=stretch>equal-height</a> 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:

		<pre class="lang-css">
			@media all and (max-width: 600px) {
				/* Too narrow to support three columns */
				main { flex-flow: column; }
				main > article, main > nav, main > aside {
					/* Return them to document order */
					order: 0; width: auto;
				}
			}
		</pre>

		<small>(Further use of multi-line flex containers to achieve even more intelligent wrapping left as an exercise for the reader.)</small>
	</div>

<!--
████████ ██       ████████ ██     ██       ██       ████ ██    ██ ████████  ██████
██       ██       ██        ██   ██        ██        ██  ███   ██ ██       ██    ██
██       ██       ██         ██ ██         ██        ██  ████  ██ ██       ██
██████   ██       ██████      ███          ██        ██  ██ ██ ██ ██████    ██████
██       ██       ██         ██ ██         ██        ██  ██  ████ ██             ██
██       ██       ██        ██   ██        ██        ██  ██   ███ ██       ██    ██
██       ████████ ████████ ██     ██       ████████ ████ ██    ██ ████████  ██████
-->

<h2 id='flex-lines'>
Flex Lines</h2>

	<a>Flex items</a> in a <a>flex container</a> are laid out and aligned
	within <dfn export lt="flex line">flex lines</dfn>,
	hypothetical containers used for grouping and alignment by the layout algorithm.
	A flex container can be either <a>single-line</a> or <a>multi-line</a>,
	depending on the 'flex-wrap' property:

	* A <dfn export local-lt="single-line">single-line flex container</dfn>
		(i.e. one with ''flex-wrap: nowrap'')
		lays out all of its children in a single line,
		even if that would cause its contents to overflow.
	* A <dfn export local-lt="multi-line">multi-line flex container</dfn>
		(i.e. one with ''flex-wrap: wrap'' or ''flex-wrap: wrap-reverse'')
		breaks its <a>flex items</a> across multiple lines,
		similar to how text is broken onto a new line when it gets too wide to fit on the existing line.
		When additional lines are created,
		they are stacked in the flex container along the <a>cross axis</a>
		according to the 'flex-wrap' property.
		Every line contains at least one <a>flex item</a>,
		unless the flex container itself is completely empty.

	<div class=example>
		This example shows four buttons that do not fit side-by-side horizontally,
		and therefore will wrap into multiple lines.

		<pre class="lang-css">
			#flex {
				display: flex;
				flex-flow: row wrap;
				width: 300px;
			}
			.item {
				width: 80px;
			}
		</pre>
		<pre class="lang-markup">
			&lt;div id="flex">
				&lt;div class="item">1&lt;/div>
				&lt;div class="item">2&lt;/div>
				&lt;div class="item">3&lt;/div>
				&lt;div class="item">4&lt;/div>
			&lt;/div>
		</pre>

		Since the container is 300px wide, only three of the items fit onto a single line.
		They take up 240px, with 60px left over of remaining space.
		Because the 'flex-flow' property specifies a <a>multi-line</a> flex container
		(due to the ''wrap'' keyword appearing in its value),
		the flex container will create an additional line to contain the last item.

		<figure>
			<img src="images/multiline-no-flex.svg" width=300 height=89 alt>
			<figcaption>An example rendering of the multi-line flex container.</figcaption>
		</figure>
	</div>

	Once content is broken into lines,
	each line is laid out independently;
	flexible lengths and the 'justify-content' and 'align-self' properties only consider the items on a single line at a time.

	In a <a>multi-line</a> <a>flex container</a> (even one with only a single line),
	the <a>cross size</a> of each line
	is the minimum size necessary to contain the <a>flex items</a> on the line
	(after alignment due to 'align-self'),
	and the lines are aligned within the flex container with the 'align-content' property.
	In a <a>single-line</a> <a>flex container</a>,
	the <a>cross size</a> of the line is the <a>cross size</a> of the flex container,
	and 'align-content' has no effect.
	The <a>main size</a> of a line is always the same as the <a>main size</a> of the flex container's content box.

	<wpt>
		align-content-001.htm
		align-content-002.htm
		align-content-003.htm
		align-content-004.htm
		align-content-005.htm
		align-content-006.htm
		align-content-007.htm
		flex-wrap-column-grow.html
		flexbox-lines-must-be-stretched-by-default.html
	</wpt>

	<div class='example'>
		Here's the same example as the previous,
		except that the flex items have all been given ''flex: auto''.
		The first line has 60px of remaining space,
		and all of the items have the same flexibility,
		so each of the three items on that line will receive 20px of extra width,
		each ending up 100px wide.
		The remaining item is on a line of its own
		and will stretch to the entire width of the line, i.e. 300px.

		<figure>
			<img src="images/multiline-flex.svg" width=300 height=89 alt>

			<figcaption>
				A rendering of the same as above,
				but with the items all given ''flex: auto''.
			</figcaption>
		</figure>
	</div>

<!--
████████ ██       ████████ ██     ██
██       ██       ██        ██   ██
██       ██       ██         ██ ██
██████   ██       ██████      ███
██       ██       ██         ██ ██
██       ██       ██        ██   ██
██       ████████ ████████ ██     ██
-->

<h2 id='flexibility'>
Flexibility</h2>

	The defining aspect of flex layout is the ability to make the <a>flex items</a> “flex”,
	altering their width/height to fill the available space in the <a>main dimension</a>.
	This is done with the 'flex' property.
	A flex container distributes free space to its items (proportional to their <a>flex grow factor</a>) to fill the container,
	or shrinks them (proportional to their <a>flex shrink factor</a>) to prevent overflow.

	A <a>flex item</a> is <dfn>fully inflexible</dfn>
	if both its 'flex-grow' and 'flex-shrink' values are zero,
	and <dfn>flexible</dfn> otherwise.

	<wpt>
		flex-factor-less-than-one.html
	</wpt>

<h3 id='flex-property'>
The 'flex' Shorthand</h3>

	<pre class='propdef shorthand'>
	Name: flex
	Value: none | [ <<'flex-grow'>> <<'flex-shrink'>>? || <<'flex-basis'>> ]
	Initial: 0 1 auto
	Applies to: <a>flex items</a>
	Inherited: no
	Animation type: by computed value type
	</pre>

	<wpt>
		flexbox-dyn-resize-001.html
		flex-item-max-width-min-content.html
		flex-item-min-height-min-content.html
		flex-item-min-width-min-content.html
		flex-shorthand-calc.html
		parsing/flex-computed.html
		parsing/flex-invalid.html
		parsing/flex-shorthand.html
		parsing/flex-valid.html
	</wpt>

	The 'flex' property specifies the components of a flexible size:
	the <dfn lt="flex factor">flex factors</dfn>
	(<a lt="flex grow factor">grow</a> and <a lt="flex shrink factor">shrink</a>)
	and the <a>flex basis</a>.
	When a box is a <a>flex item</a>,
	'flex' is consulted <em>instead of</em> the <a>main size property</a>
	to determine the <a>main size</a> of the box.
	If a box is not a <a>flex item</a>,
	'flex' has no effect.

	Note: The initial values of the 'flex' longhands are equivalent to
	<a class="css-code" href="#flex-initial">flex: 0 1 auto</a>.
	This differs from their defaults when omitted in the 'flex' shorthand
	(effectively ''1 1 0px'')
	so that the 'flex' shorthand can better accommodate
	<a href="#flex-common">the most common cases</a>.

	<dl dfn-type=value dfn-for=flex>
		<dt><dfn><<'flex-grow'>></dfn>
		<dd>
			This <<number [0,∞]>> component sets 'flex-grow' <a href="#flex-components">longhand</a>
			and specifies the <dfn dfn>flex grow factor</dfn>,
			which determines how much the <a>flex item</a> will grow
			relative to the rest of the <a>flex items</a> in the flex container
			when positive free space is distributed.
			When omitted, it is set to ''1''.

			<wpt>
				animation/flex-grow-interpolation.html
				flex-001.htm
				flex-003.htm
				flex-grow-001.xht
				flex-grow-002.html
				flex-grow-003.html
				flex-grow-004.html
				flex-grow-005.html
				flex-grow-006.html
				flex-grow-007.html
				flex-grow-008.html
				flexbox_flex-natural.html
				flexbox_flex-natural-mixed-basis-auto.html
				flexbox_flex-natural-mixed-basis.html
				flexbox_flex-natural-variable-auto-basis.html
				flexbox_flex-natural-variable-zero-basis.html
				flexbox_flex-none.html
				flexbox_flex-none-wrappable-content.html
				flex-factor-less-than-one.html
				getcomputedstyle/flexbox_computedstyle_flex-shorthand-0-auto.html
				getcomputedstyle/flexbox_computedstyle_flex-shorthand-auto.html
				getcomputedstyle/flexbox_computedstyle_flex-shorthand.html
				getcomputedstyle/flexbox_computedstyle_flex-shorthand-initial.html
				getcomputedstyle/flexbox_computedstyle_flex-shorthand-invalid.html
				getcomputedstyle/flexbox_computedstyle_flex-shorthand-none.html
				getcomputedstyle/flexbox_computedstyle_flex-shorthand-number.html
				getcomputedstyle/flexbox_computedstyle_flex-grow-0.html
				getcomputedstyle/flexbox_computedstyle_flex-grow-invalid.html
				getcomputedstyle/flexbox_computedstyle_flex-grow-number.html
				interactive/flexbox_interactive_flex-grow-transitions.html
				parsing/flex-grow-computed.html
				parsing/flex-grow-invalid.html
				parsing/flex-grow-valid.html
				table-item-flex-percentage-min-width.html
				table-item-flex-percentage-width.html
				flex-rounding.html
			</wpt>

			<details class=note>
				<summary>Flex values between 0 and 1 have a somewhat special behavior:
				when the sum of the flex values on the line is less than 1,
				they will take up less than 100% of the free space.</summary>

				An item’s 'flex-grow' value
				is effectively a request for some proportion of the free space,
				with ''1'' meaning “100% of the free space”;
				then if the items on the line are requesting more than 100% in total,
				the requests are rebalanced to keep the same ratio but use up exactly 100% of it.
				However, if the items request <em>less</em> than the full amount
				(such as three items that are each ''flex-grow: .25'')
				then they'll each get exactly what they request
				(25% of the free space to each,
				with the final 25% left unfilled).
				See [[#resolve-flexible-lengths]] for the exact details
				of how free space is distributed.

				This pattern is required for continuous behavior as 'flex-grow' approaches zero
				(which means the item wants <em>none</em> of the free space).
				Without this, a ''flex-grow: 1'' item would take all of the free space;
				but so would a ''flex-grow: 0.1'' item,
				and a ''flex-grow: 0.01'' item,
				etc.,
				until finally the value is small enough to underflow to zero
				and the item suddenly takes up none of the free space.
				With this behavior,
				the item instead gradually takes less of the free space
				as 'flex-grow' shrinks below ''1'',
				smoothly transitioning to taking none of the free space at zero.

				Unless this “partial fill” behavior is <em>specifically</em> what's desired,
				authors should stick to values &ge; 1;
				for example, using ''1'' and ''2'' is usually better
				than using ''.33'' and ''.67'',
				as they're more likely to behave as intended
				if items are added, removed, or line-wrapped.
			</details>

		<dt><dfn><<'flex-shrink'>></dfn>
		<dd>
			This <<number [0,∞]>> component sets 'flex-shrink' <a href="#flex-components">longhand</a>
			and specifies the <dfn dfn>flex shrink factor</dfn>,
			which determines how much the <a>flex item</a> will shrink
			relative to the rest of the <a>flex items</a> in the flex container
			when negative free space is distributed.
			When omitted, it is set to ''1''.

			<wpt>
				animation/flex-shrink-interpolation.html
				flex-002.htm
				flex-004.htm
				flex-factor-less-than-one.html
				flex-shrink-001.html
				flex-shrink-002.html
				flex-shrink-003.html
				flex-shrink-004.html
				flex-shrink-005.html
				flex-shrink-006.html
				flex-shrink-007.html
				flex-shrink-008.html
				flex-shrink-large-value-crash.html
				getcomputedstyle/flexbox_computedstyle_flex-shrink-0.html
				getcomputedstyle/flexbox_computedstyle_flex-shrink-invalid.html
				getcomputedstyle/flexbox_computedstyle_flex-shrink-number.html
				interactive/flexbox_interactive_flex-shrink-transitions.html
				interactive/flexbox_interactive_flex-shrink-transitions-invalid.html
				parsing/flex-shrink-computed.html
				parsing/flex-shrink-invalid.html
				parsing/flex-shrink-valid.html
				table-item-flex-percentage-min-width.html
				table-item-flex-percentage-width.html
			</wpt>

			Note: The <a>flex shrink factor</a> is multiplied by the <a>flex base size</a> when distributing negative space.
			This distributes negative space in proportion to how much the item is able to shrink,
			so that e.g. a small item won't shrink to zero before a larger item has been noticeably reduced.

			<wpt>
				flex-item-max-width-min-content-002.html
			</wpt>

		<dt><dfn><<'flex-basis'>></dfn>
		<dd>
			This component sets the 'flex-basis' <a href="#flex-components">longhand</a>,
			which specifies the <dfn dfn>flex basis</dfn>:
			the initial <a>main size</a> of the <a>flex item</a>,
			before free space is distributed according to the flex factors.

			<wpt>
				animation/flex-basis-composition.html
				animation/flex-basis-content-crash.html
				animation/flex-basis-interpolation.html
				dynamic-isize-change-001.html
				dynamic-isize-change-002.html
				dynamic-isize-change-003.html
				dynamic-isize-change-004.html
				flex-basis-001.html
				flex-basis-002.html
				flex-basis-003.html
				flex-basis-004.html
				flex-basis-005.html
				flex-basis-006.html
				flex-basis-007.html
				flex-basis-008.html
				flex-basis-009.html
				flex-basis-010.html
				flex-basis-011.html
				flex-basis-012.html
				flex-basis-013.html
				flex-basis-intrinsics-001.html
				flex-basis-item-margins-001.html
				flexbox-flex-basis-content-001a.html
				flexbox-flex-basis-content-001b.html
				flexbox-flex-basis-content-002a.html
				flexbox-flex-basis-content-002b.html
				flexbox-flex-basis-content-003a.html
				flexbox-flex-basis-content-003b.html
				flexbox-flex-basis-content-004a.html
				flexbox-flex-basis-content-004b.html
				flexbox_flex-basis.html
				flexbox_flex-basis-shrink.html
				flex-one-sets-flex-basis-to-zero-px.html
				flex-shorthand-flex-basis-middle.html
				getcomputedstyle/flexbox_computedstyle_flex-basis-0.html
				getcomputedstyle/flexbox_computedstyle_flex-basis-0percent.html
				getcomputedstyle/flexbox_computedstyle_flex-basis-auto.html
				getcomputedstyle/flexbox_computedstyle_flex-basis-percent.html
				interactive/flexbox_interactive_flex-basis-transitions.html
				parsing/flex-basis-computed.html
				parsing/flex-basis-invalid.html
				parsing/flex-basis-valid.html
				table-as-item-percent-width-cell-001.html
			</wpt>

			<<'flex-basis'>> accepts the same values as the 'width' and 'height' properties
			(except that ''flex-basis/auto'' is treated differently)
			plus the ''content'' keyword:

			<dl dfn-type=value dfn-for=flex-basis>
				<dt><dfn>auto</dfn>
				<dd>
					When specified on a <a>flex item</a>, the ''flex-basis/auto'' keyword
					retrieves the value of the <a>main size property</a> as the used 'flex-basis'.
					If that value is itself ''auto'', then the used value is ''flex-basis/content''.

				<dt><dfn>content</dfn>
				<dd>
					Indicates an [=automatic size=]
					based on the <a>flex item</a>’s content.
					(This is typically equivalent to the <a>max-content size</a>,
					but with adjustments to handle [=preferred aspect ratios=],
					intrinsic sizing constraints,
					and orthogonal flows;
					see <a href="#algo-main-item">details</a> in [[#layout-algorithm]].)

					Note: This value was not present in the initial release of Flexible Box Layout,
					and thus some older implementations will not support it.
					The equivalent effect can be achieved by using ''flex/auto''
					together with a main size ('width' or 'height') of ''width/auto''.

				<dt><<'width'>>
				<dd>
					For all other values,
					'flex-basis' is resolved the same way as for 'width' and 'height'.
			</dl>

			When omitted from the 'flex' shorthand, its specified value is ''0''.

		<dt><dfn>none</dfn>
		<dd>
			The keyword ''flex/none'' expands to ''0 0 auto''.
	</dl>

	<figure>
		<img src='images/rel-vs-abs-flex.svg' width='504' height='240'>
		<figcaption>
			A diagram showing the difference between "absolute" flex
			(starting from a basis of zero)
			and "relative" flex
			(starting from a basis of the item's content size).
			The three items have flex factors of ''1'', ''1'', and ''2'', respectively:
			notice that the item with a flex factor of ''2'' grows twice as fast as the others.
		</figcaption>
	</figure>

	A unitless zero that is not already preceded by two flex factors
	must be interpreted as a flex factor.
	To avoid misinterpretation or invalid declarations,
	authors must specify a zero <<'flex-basis'>> component
	with a unit or precede it by two flex factors.

<h4 id='flex-common'>
Basic Values of 'flex'</h4>

	<em>This section is informative.</em>

	The list below summarizes the effects of the four 'flex' values
	that represent most commonly-desired effects:

	<dl>
		<dt id="flex-initial">''flex: initial''
		<dd>
			Equivalent to ''flex: 0 1 auto''. (This is the initial value.)
			Sizes the item based on the 'width'/'height' properties.
			(If the item's <a>main size property</a> computes to <a value for=width>auto</a>,
			this will size the flex item based on its contents.)
			Makes the flex item inflexible when there is positive free space,
			but allows it to shrink to its minimum size when there is insufficient space.
			The <a href="#alignment">alignment abilities</a> or <a href="#auto-margins"><span class=css>auto</span> margins</a>
			can be used to align flex items along the <a>main axis</a>.

		<dt>''flex: auto''
		<dd>
			Equivalent to ''flex: 1 1 auto''.
			Sizes the item based on the 'width'/'height' properties,
			but makes them fully flexible, so that they absorb any free space along the <a>main axis</a>.
			If all items are either ''flex: auto'', ''flex: initial'', or ''flex: none'',
			any positive free space after the items have been sized will be distributed evenly to the items with ''flex: auto''.

		<dt>''flex: none''
		<dd>
			Equivalent to ''flex: 0 0 auto''.
			This value sizes the item according to the 'width'/'height' properties,
			but makes the flex item <a>fully inflexible</a>.
			This is similar to ''initial'',
			except that flex items are not allowed to shrink,
			even in overflow situations.

		<dt>''flex: &lt;number [1,∞]>''
		<dd>
			Equivalent to ''flex: &lt;number [1,∞]> 1 0''.
			Makes the flex item flexible and sets the <a>flex basis</a> to zero,
			resulting in an item that receives the specified proportion of the free space in the flex container.
			If all items in the flex container use this pattern,
			their sizes will be proportional to the specified flex factor.
	</dl>

	<wpt>
		flexbox_flex-auto.html
		flexbox_flex-initial-2.html
		flexbox_flex-initial.html
		radiobutton-min-size.html
	</wpt>

	By default, flex items won't shrink below their minimum content size
	(the length of the longest word or fixed-size element).
	To change this, set the 'min-width' or 'min-height' property.
	(See [[#min-size-auto]].)

<h3 id='flex-components'>
Components of Flexibility</h3>

	Individual components of flexibility can be controlled by independent longhand properties.

	Advisement: Authors are encouraged to control flexibility using the 'flex' shorthand
	rather than with its longhand properties directly,
	as the shorthand correctly resets any unspecified components
	to accommodate <a href="#flex-common">common uses</a>.

<h4 id='flex-grow-property'>
The 'flex-grow' property</h4>

	<pre class='propdef'>
	Name: flex-grow
	Value: <<number [0,∞]>>
	Initial: 0
	Applies to: <a>flex items</a>
	Inherited: no
	Computed value: specified number
	Animation type: by computed value type
	</pre>

	
	<wpt>
		animation/flex-grow-interpolation.html
		flex-001.htm
		flex-003.htm
		flex-grow-001.xht
		flex-grow-002.html
		flex-grow-003.html
		flex-grow-004.html
		flex-grow-005.html
		flex-grow-006.html
		flex-grow-007.html
		flex-grow-008.html
		getcomputedstyle/flexbox_computedstyle_flex-grow-0.html
		getcomputedstyle/flexbox_computedstyle_flex-grow-invalid.html
		getcomputedstyle/flexbox_computedstyle_flex-grow-number.html
		interactive/flexbox_interactive_flex-grow-transitions.html
		parsing/flex-grow-computed.html
		parsing/flex-grow-invalid.html
		parsing/flex-grow-valid.html
	</wpt>

	Advisement: Authors are encouraged to control flexibility using the 'flex' shorthand
	rather than with 'flex-grow' directly,
	as the shorthand correctly resets any unspecified components
	to accommodate <a href="#flex-common">common uses</a>.

	The 'flex-grow' property sets the <a>flex grow factor</a>
	to the provided <dfn value for=flex-grow><<number>></dfn>.
	Negative values are not allowed.

<h4 id='flex-shrink-property'>
The 'flex-shrink' property</h4>

	<pre class='propdef'>
	Name: flex-shrink
	Value: <<number [0,∞]>>
	Initial: 1
	Applies to: <a>flex items</a>
	Inherited: no
	Computed value: specified value
	Animation type: number
	</pre>

	<wpt>
		animation/flex-shrink-interpolation.html
		flex-002.htm
		flex-004.htm
		flex-shrink-001.html
		flex-shrink-002.html
		flex-shrink-003.html
		flex-shrink-004.html
		flex-shrink-005.html
		flex-shrink-006.html
		flex-shrink-007.html
		flex-shrink-008.html
		flex-shrink-large-value-crash.html
		getcomputedstyle/flexbox_computedstyle_flex-shrink-0.html
		getcomputedstyle/flexbox_computedstyle_flex-shrink-invalid.html
		getcomputedstyle/flexbox_computedstyle_flex-shrink-number.html
		interactive/flexbox_interactive_flex-shrink-transitions.html
		interactive/flexbox_interactive_flex-shrink-transitions-invalid.html
		parsing/flex-shrink-computed.html
		parsing/flex-shrink-invalid.html
		parsing/flex-shrink-valid.html
	</wpt>

	Advisement: Authors are encouraged to control flexibility using the 'flex' shorthand
	rather than with 'flex-shrink' directly,
	as the shorthand correctly resets any unspecified components
	to accommodate <a href="#flex-common">common uses</a>.

	The 'flex-shrink' property sets the <a>flex shrink factor</a>
	to the provided <dfn value for=flex-shrink><<number>></dfn>.
	Negative values are not allowed.

<h4 id='flex-basis-property'>
The 'flex-basis' property</h4>

	<pre class='propdef'>
	Name: flex-basis
	Value: content | <<'width'>>
	Initial: auto
	Applies to: <a>flex items</a>
	Inherited: no
	Percentages: relative to the <a>flex container's</a> inner <a>main size</a>
	Computed value: specified keyword or a computed <<length-percentage>> value
	Animation type: by computed value type
	</pre>

	<wpt>
		animation/flex-basis-composition.html
		animation/flex-basis-content-crash.html
		animation/flex-basis-interpolation.html
		dynamic-isize-change-001.html
		dynamic-isize-change-002.html
		dynamic-isize-change-003.html
		dynamic-isize-change-004.html
		flex-basis-001.html
		flex-basis-002.html
		flex-basis-003.html
		flex-basis-004.html
		flex-basis-005.html
		flex-basis-006.html
		flex-basis-007.html
		flex-basis-008.html
		flex-basis-009.html
		flex-basis-010.html
		flex-basis-011.html
		flex-basis-012.html
		flex-basis-013.html
		flex-basis-content-percentage-height.html
		flex-basis-intrinsics-001.html
		flex-basis-item-margins-001.html
		flexbox-flex-basis-content-001a.html
		flexbox-flex-basis-content-001b.html
		flexbox-flex-basis-content-002a.html
		flexbox-flex-basis-content-002b.html
		flexbox-flex-basis-content-003a.html
		flexbox-flex-basis-content-003b.html
		flexbox-flex-basis-content-004a.html
		flexbox-flex-basis-content-004b.html
		flexbox_flex-basis.html
		flexbox_flex-basis-shrink.html
		flex-one-sets-flex-basis-to-zero-px.html
		flex-shorthand-flex-basis-middle.html
		getcomputedstyle/flexbox_computedstyle_flex-basis-0.html
		getcomputedstyle/flexbox_computedstyle_flex-basis-0percent.html
		getcomputedstyle/flexbox_computedstyle_flex-basis-auto.html
		getcomputedstyle/flexbox_computedstyle_flex-basis-percent.html
		interactive/flexbox_interactive_flex-basis-transitions.html
		parsing/flex-basis-computed.html
		parsing/flex-basis-invalid.html
		parsing/flex-basis-valid.html
	</wpt>

	Advisement: Authors are encouraged to control flexibility using the 'flex' shorthand
	rather than with 'flex-basis' directly,
	as the shorthand correctly resets any unspecified components
	to accommodate <a href="#flex-common">common uses</a>.

	The 'flex-basis' property sets the <a>flex basis</a>.
	It accepts the same values as the 'width' and 'height' property, plus ''content''.

	For all values other than ''flex-basis/auto'' and ''content'' (defined above),
	'flex-basis' is resolved the same way as 'width' in horizontal writing modes [[!CSS2]],
	except that if a value would resolve to ''width/auto'' for 'width',
	it instead resolves to ''content'' for 'flex-basis'.
	For example, percentage values of 'flex-basis' are resolved against
	the flex item's containing block (i.e. its <a>flex container</a>);
	and if that containing block's size is <a>indefinite</a>,
	the used value for 'flex-basis' is ''content''.
	As another corollary,
	'flex-basis' determines the size of the content box,
	unless otherwise specified
	such as by 'box-sizing' [[CSS3UI]].

<h2 id='alignment'>
Alignment</h2>

	After a flex container's contents have finished their flexing
	and the dimensions of all flex items are finalized,
	they can then be aligned within the flex container.

	The 'margin' properties can be used to align items in a manner similar to, but more powerful than, what margins can do in block layout.
	<a>Flex items</a> also respect the alignment properties from <a href="https://www.w3.org/TR/css3-align/">CSS Box Alignment</a>,
	which allow easy keyword-based alignment of items in both the <a>main axis</a> and <a>cross axis</a>.
	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.

	Note: While the alignment properties are defined in <a href="https://www.w3.org/TR/css3-align/">CSS Box Alignment</a> [[!CSS-ALIGN-3]],
	Flexible Box Layout reproduces the definitions of the relevant ones here
	so as to not create a normative dependency that may slow down advancement of the spec.
	These properties apply only to flex layout
	until <a href="https://www.w3.org/TR/css3-align/">CSS Box Alignment Level 3</a> is finished
	and defines their effect for other layout modes.
	Additionally, any new values defined in the Box Alignment module
	will apply to Flexible Box Layout;
	in other words, the Box Alignment module, once completed,
	will supersede the definitions here.

	<wpt>
		baseline-outside-flex-item.html
		fieldset-baseline-alignment.html
	</wpt>

<!--
██     ██    ███    ████████   ██████   ████ ██    ██  ██████
███   ███   ██ ██   ██     ██ ██    ██   ██  ███   ██ ██    ██
████ ████  ██   ██  ██     ██ ██         ██  ████  ██ ██
██ ███ ██ ██     ██ ████████  ██   ████  ██  ██ ██ ██  ██████
██     ██ █████████ ██   ██   ██    ██   ██  ██  ████       ██
██     ██ ██     ██ ██    ██  ██    ██   ██  ██   ███ ██    ██
██     ██ ██     ██ ██     ██  ██████   ████ ██    ██  ██████
-->

<h3 id='auto-margins'>
Aligning with <a value for=margin>auto</a> margins</h3>

	<em>This section is non-normative.
		The normative definition of how margins affect flex items is in the <a href="#layout-algorithm">Flex Layout Algorithm</a> section.</em>

	Auto margins on flex items have an effect very similar to auto margins in block flow:

	* During calculations of flex bases and flexible lengths, auto margins are treated as ''0''.
	* Prior to alignment via 'justify-content' and 'align-self',
		any positive free space is distributed to auto margins in that dimension.
	* Overflowing boxes ignore their auto margins and overflow in the <a>end</a> direction.

	<wpt>
		auto-height-column-with-border-and-padding.html
		auto-height-with-flex.html
		auto-margins-001.html
		auto-margins-002.html
		auto-margins-003.html
		flexbox-margin-auto-horiz-001.xhtml
		flexbox-margin-auto-horiz-002.xhtml
		flexbox_margin-auto.html
		flexbox_margin-auto-overflow.html
		main-axis-margin-rounding.html
	</wpt>

	Note: If free space is distributed to auto margins,
	the alignment properties will have no effect in that dimension
	because the margins will have stolen all the free space
	left over after flexing.

	<div class='example'>
		One use of ''margin/auto'' margins in the main axis is to separate flex items into distinct "groups".
		The following example shows how to use this to reproduce a common UI pattern -
		a single bar of actions with some aligned on the left and others aligned on the right.

		<figure>
			<figcaption>
				Sample rendering of the code below.
			</figcaption>
			<ul id='auto-bar'>
				<li><a href=#>About</a>
				<li><a href=#>Projects</a>
				<li><a href=#>Interact</a>
				<li id='login'><a href=#>Login</a>
			</ul>
		</figure>

		<pre class="lang-css">
			nav > ul {
				display: flex;
			}
			nav > ul > #login {
				margin-left: auto;
			}
		</pre>
		<pre class="lang-markup">
			&lt;nav>
				&lt;ul>
					&lt;li>&lt;a href=/about>About&lt;/a>
					&lt;li>&lt;a href=/projects>Projects&lt;/a>
					&lt;li>&lt;a href=/interact>Interact&lt;/a>
					&lt;li id="login">&lt;a href=/login>Login&lt;/a>
				&lt;/ul>
			&lt;/nav>
		</pre>
	</div>

	<div class='example'>
		The figure below illustrates the difference in cross-axis alignment in overflow situations between
		using <a href="#auto-margins"><css>auto</css> margins</a>
		and using the <a property lt="align-items">alignment properties</a>.

		<figure>
			<div style="display:table; margin: 0 auto 1em;">
				<div style="display:table-cell; padding-right: 50px;" class='cross-auto-figure'>
					<div>
						<div>About</div>
						<div>Authoritarianism</div>
						<div>Blog</div>
					</div>
				</div>
				<div style="display:table-cell; padding-left: 50px;" class='cross-auto-figure'>
					<div>
						<div>About</div>
						<div style="margin-left: -31px;">Authoritarianism</div>
						<div>Blog</div>
					</div>
				</div>
			</div>
			<figcaption>
				The items in the figure on the left are centered with margins,
				while those in the figure on the right are centered with 'align-self'.
				If this column flex container was placed against the left edge of the page,
				the margin behavior would be more desirable,
				as the long item would be fully readable.
				In other circumstances,
				the true centering behavior might be better.
			</figcaption>
		</figure>
	</div>

<!--
      ██ ██     ██  ██████  ████████ ████ ████████ ██    ██          ██████   ███████  ██    ██ ████████ ████████ ██    ██ ████████
      ██ ██     ██ ██    ██    ██     ██  ██        ██  ██          ██    ██ ██     ██ ███   ██    ██    ██       ███   ██    ██
      ██ ██     ██ ██          ██     ██  ██         ████           ██       ██     ██ ████  ██    ██    ██       ████  ██    ██
      ██ ██     ██  ██████     ██     ██  ██████      ██    ███████ ██       ██     ██ ██ ██ ██    ██    ██████   ██ ██ ██    ██
██    ██ ██     ██       ██    ██     ██  ██          ██            ██       ██     ██ ██  ████    ██    ██       ██  ████    ██
██    ██ ██     ██ ██    ██    ██     ██  ██          ██            ██    ██ ██     ██ ██   ███    ██    ██       ██   ███    ██
 ██████   ███████   ██████     ██    ████ ██          ██             ██████   ███████  ██    ██    ██    ████████ ██    ██    ██
-->

<h3 id='justify-content-property'>
Axis Alignment: the 'justify-content' property</h3>

	<pre class='propdef'>
	Name: justify-content
	Value: flex-start | flex-end | center | space-between | space-around
	Initial: flex-start
	Applies to: <a>flex containers</a>
	Inherited: no
	Computed value: specified keyword
	Animation type: discrete
	</pre>

	<wpt>
		dynamic-isize-change-001.html
		dynamic-isize-change-002.html
		dynamic-isize-change-003.html
		dynamic-isize-change-004.html
		flexbox_justifycontent-center.html
		flexbox_justifycontent-center-overflow.html
		flexbox_justifycontent-end.html
		flexbox_justifycontent-end-rtl.html
		flexbox_justifycontent-flex-end.html
		flexbox_justifycontent-flex-start.html
		flexbox-justify-content-horiz-001a.xhtml
		flexbox-justify-content-horiz-001b.xhtml
		flexbox-justify-content-horiz-002.xhtml
		flexbox-justify-content-horiz-003.xhtml
		flexbox-justify-content-horiz-004.xhtml
		flexbox-justify-content-horiz-005.xhtml
		flexbox-justify-content-horiz-006.xhtml
		flexbox_justifycontent-left-001.html
		flexbox_justifycontent-left-002.html
		flexbox_justifycontent-right-001.html
		flexbox_justifycontent-right-002.html
		flexbox_justifycontent-rtl-001.html
		flexbox_justifycontent-rtl-002.html
		flexbox_justifycontent-spacearound.html
		flexbox_justifycontent-spacearound-negative.html
		flexbox_justifycontent-spacearound-only.html
		flexbox_justifycontent-spacebetween.html
		flexbox_justifycontent-spacebetween-negative.html
		flexbox_justifycontent-spacebetween-only.html
		flexbox_justifycontent-start.html
		flexbox_justifycontent-start-rtl.html
		flexbox_justifycontent-stretch.html
		flexbox-justify-content-vert-001a.xhtml
		flexbox-justify-content-vert-001b.xhtml
		flexbox-justify-content-vert-002.xhtml
		flexbox-justify-content-vert-003.xhtml
		flexbox-justify-content-vert-004.xhtml
		flexbox-justify-content-vert-005.xhtml
		flexbox-justify-content-vert-006.xhtml
		flexbox-justify-content-wmvert-001.xhtml
		flexbox-justify-content-wmvert-002.html
		flexbox-justify-content-wmvert-003.html
		flexbox_margin.html
		flexbox_margin-left-ex.html
		getcomputedstyle/flexbox_computedstyle_justify-content-center.html
		getcomputedstyle/flexbox_computedstyle_justify-content-flex-end.html
		getcomputedstyle/flexbox_computedstyle_justify-content-flex-start.html
		getcomputedstyle/flexbox_computedstyle_justify-content-space-around.html
		getcomputedstyle/flexbox_computedstyle_justify-content-space-between.html
		justify-content-001.htm
		justify-content-002.htm
		justify-content-003.htm
		justify-content-004.htm
		justify-content-005.htm
		justify-content-006.html
		justify-content-007.html
		justify-content_center.html
		justify-content_flex-end.html
		justify-content_flex-start.html
		justify-content-sideways-001.html
		justify-content_space-around.html
		justify-content_space-between-001.html
		justify-content_space-between-002.html
		scrollbars-auto.html
		scrollbars.html
		scrollbars-no-margin.html
		justify-content-rounding.html
	</wpt>

	The 'justify-content' property aligns <a>flex items</a> along the <a>main axis</a> of the current line of the flex container.
	This is done <em>after</em> any flexible lengths and any <a href="#auto-margins">auto margins</a> have been resolved.
	Typically it helps distribute extra free space leftover when either
	all the <a>flex items</a> on a line are inflexible,
	or are flexible but have reached their maximum size.
	It also exerts some control over the alignment of items when they overflow the line.

	<dl dfn-type=value dfn-for=justify-content>
		<dt><dfn>flex-start</dfn>
		<dd>
			<a>Flex items</a> are packed toward the start of the line.
			The <a>main-start</a> margin edge of the first <a>flex item</a> on the line
			is placed flush with the <a>main-start</a> edge of the line,
			and each subsequent <a>flex item</a> is placed flush with the preceding item.

		<wpt>
			flexbox_justifycontent-start.html
			flexbox_justifycontent-start-rtl.html
		</wpt>

		<dt><dfn>flex-end</dfn>
		<dd>
			<a>Flex items</a> are packed toward the end of the line.
			The <a>main-end</a> margin edge of the last <a>flex item</a>
			is placed flush with the <a>main-end</a> edge of the line,
			and each preceding <a>flex item</a> is placed flush with the subsequent item.

			<wpt>
				css-box-justify-content.html
				flexbox_justifycontent-end.html
				flexbox_justifycontent-end-rtl.html
				flexbox_justifycontent-flex-end.html
			</wpt>

		<dt><dfn>center</dfn>
		<dd>
			<a>Flex items</a> are packed toward the center of the line.
			The <a>flex items</a> on the line are placed flush with each other
			and aligned in the center of the line,
			with equal amounts of space between the <a>main-start</a> edge of the line and the first item on the line
			and between the <a>main-end</a> edge of the line and the last item on the line.
			(If the leftover free-space is negative,
			the <a>flex items</a> will overflow equally in both directions.)

			<wpt>
				flexbox_justifycontent-center.html
				flexbox_justifycontent-center-overflow.html
			</wpt>

		<dt><dfn>space-between</dfn>
		<dd>
			<a>Flex items</a> are evenly distributed in the line.
			If the leftover free-space is negative
			or there is only a single <a>flex item</a> on the line,
			this value falls back to ''safe flex-start''.
			Otherwise,
			the <a>main-start</a> margin edge of the first <a>flex item</a> on the line
			is placed flush with the <a>main-start</a> edge of the line,
			the <a>main-end</a> margin edge of the last <a>flex item</a> on the line
			is placed flush with the <a>main-end</a> edge of the line,
			and the remaining <a>flex items</a> on the line are distributed
			so that the spacing between any two adjacent items is the same.

			<wpt>
				flexbox_justifycontent-spacebetween.html
				flexbox_justifycontent-spacebetween-negative.html
				flexbox_justifycontent-spacebetween-only.html
			</wpt>

		<dt><dfn>space-around</dfn>
		<dd>
			<a>Flex items</a> 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 <a>flex item</a> on the line,
			this value falls back to ''safe center''.
			Otherwise, the <a>flex items</a> on the line are distributed
			such that the spacing between any two adjacent <a>flex items</a> on the line is the same,
			and the spacing between the first/last <a>flex items</a> and the <a>flex container</a> edges
			is half the size of the spacing between <a>flex items</a>.

			<wpt>
				flexbox-column-row-gap-001.html
				flexbox-column-row-gap-002.html
				flexbox-column-row-gap-003.html
				flexbox-column-row-gap-004.html
				flexbox_columns-flexitems-2.html
				flexbox_columns-flexitems.html
				flexbox_justifycontent-spacearound.html
				flexbox_justifycontent-spacearound-negative.html
				flexbox_justifycontent-spacearound-only.html
				
			</wpt>
	</dl>

	<div class="figure">
		<img src="images/flex-pack.svg" width=504 height=270 alt>
		<p class='caption'>An illustration of the five 'justify-content' keywords and their effects on a flex container with three colored items.
	</div>

<!--
   ███    ██       ████  ██████   ██    ██
  ██ ██   ██        ██  ██    ██  ███   ██          ██   ██
 ██   ██  ██        ██  ██        ████  ██           ██ ██
██     ██ ██        ██  ██   ████ ██ ██ ██ ███████ █████████
█████████ ██        ██  ██    ██  ██  ████           ██ ██
██     ██ ██        ██  ██    ██  ██   ███          ██   ██
██     ██ ████████ ████  ██████   ██    ██
-->

<h3 id='align-items-property'>
Cross-axis Alignment: the 'align-items' and 'align-self' properties</h3>

	<pre class='propdef'>
	Name: align-items
	Value: flex-start | flex-end | center | baseline | stretch
	Initial: stretch
	Applies to: <a>flex containers</a>
	Inherited: no
	Computed value: specified keyword
	Animation type: discrete
	</pre>

	<wpt>
		align-items-007.html
		align-items-008.html
		align-items-009.html
		align-items-baseline-column-horz.html
		align-items-baseline-column-vert.html
		align-items-baseline-column-vert-lr-flexbox-item.html
		align-items-baseline-column-vert-lr-grid-item.html
		align-items-baseline-column-vert-lr-items.html
		align-items-baseline-column-vert-lr-table-item.html
		align-items-baseline-column-vert-rl-flexbox-item.html
		align-items-baseline-column-vert-rl-grid-item.html
		align-items-baseline-column-vert-rl-items.html
		align-items-baseline-column-vert-rl-table-item.html
		align-items-baseline-overflow-non-visible.html
		align-items-baseline-row-horz.html
		align-items-baseline-row-vert.html
		align-items-baseline-vert-lr-column-horz-flexbox-item.html
		align-items-baseline-vert-lr-column-horz-grid-item.html
		align-items-baseline-vert-lr-column-horz-items.html
		align-items-baseline-vert-lr-column-horz-table-item.html
		align-items-baseline-vert-rl-column-horz-flexbox-item.html
		align-items-baseline-vert-rl-column-horz-grid-item.html
		align-items-baseline-vert-rl-column-horz-items.html
		align-items-baseline-vert-rl-column-horz-table-item.html
		alignment/multiline-align-self.html
		column-flex-child-with-max-width.html
		dynamic-stretch-change.html
		flexbox_align-items-baseline.html
		flexbox_align-items-center-2.html
		flexbox_align-items-center-3.html
		flexbox_align-items-center.html
		flexbox-align-items-center-nested-001.html
		flexbox_align-items-flexend-2.html
		flexbox_align-items-flexend.html
		flexbox_align-items-flexstart-2.html
		flexbox_align-items-flexstart.html
		flexbox_align-items-stretch-2.html
		flexbox_align-items-stretch-3.html
		flexbox_align-items-stretch-4.html
		flexbox_align-items-stretch.html
		getcomputedstyle/flexbox_computedstyle_align-items-baseline.html
		getcomputedstyle/flexbox_computedstyle_align-items-center.html
		getcomputedstyle/flexbox_computedstyle_align-items-flex-end.html
		getcomputedstyle/flexbox_computedstyle_align-items-flex-start.html
		getcomputedstyle/flexbox_computedstyle_align-items-invalid.html
		getcomputedstyle/flexbox_computedstyle_align-items-stretch.html
		position-relative-percentage-top-001.html
		position-relative-percentage-top-002.html
		position-relative-percentage-top-003.html
		relayout-align-items.html
		stretch-input-in-column.html
		stretch-requires-computed-auto-size.html
		table-as-item-stretch-cross-size-2.html
		table-as-item-stretch-cross-size-3.html
		table-as-item-stretch-cross-size-4.html
		table-as-item-stretch-cross-size-5.html
		table-as-item-stretch-cross-size.html
	</wpt>

	<pre class='propdef'>
	Name: align-self
	Value: auto | flex-start | flex-end | center | baseline | stretch
	Initial: auto
	Applies to: <a>flex items</a>
	Inherited: no
	Computed value: specified keyword
	Animation type: discrete
	</pre>

	<wpt>
		align-self-006.html
		align-self-010.html
		align-self-013.html
		align-self-014.html
		align-self-015.html
		align-self-016.html
		flexbox_align-self-auto.html
		flexbox-align-self-baseline-compatability.html
		flexbox-align-self-baseline-horiz-001a.xhtml
		flexbox-align-self-baseline-horiz-001b.xhtml
		flexbox-align-self-baseline-horiz-002.xhtml
		flexbox-align-self-baseline-horiz-003.xhtml
		flexbox-align-self-baseline-horiz-004.xhtml
		flexbox-align-self-baseline-horiz-005.xhtml
		flexbox-align-self-baseline-horiz-006.xhtml
		flexbox-align-self-baseline-horiz-007.xhtml
		flexbox-align-self-baseline-horiz-008.xhtml
		flexbox_align-self-baseline.html
		flexbox_align-self-center.html
		flexbox_align-self-flexend.html
		flexbox_align-self-flexstart.html
		flexbox-align-self-horiz-001-block.xhtml
		flexbox-align-self-horiz-001-table.xhtml
		flexbox-align-self-horiz-002.xhtml
		flexbox-align-self-horiz-003.xhtml
		flexbox-align-self-horiz-004.xhtml
		flexbox-align-self-horiz-005.xhtml
		flexbox_align-self-stretch.html
		flexbox-align-self-stretch-vert-001.html
		flexbox-align-self-stretch-vert-002.html
		flexbox-align-self-vert-001.xhtml
		flexbox-align-self-vert-002.xhtml
		flexbox-align-self-vert-003.xhtml
		flexbox-align-self-vert-004.xhtml
		flexbox-align-self-vert-rtl-001.xhtml
		flexbox-align-self-vert-rtl-002.xhtml
		flexbox-align-self-vert-rtl-003.xhtml
		flexbox-align-self-vert-rtl-004.xhtml
		flexbox-align-self-vert-rtl-005.xhtml
		getcomputedstyle/flexbox_computedstyle_align-self-baseline.html
		getcomputedstyle/flexbox_computedstyle_align-self-center.html
		getcomputedstyle/flexbox_computedstyle_align-self-flex-end.html
		getcomputedstyle/flexbox_computedstyle_align-self-flex-start.html
		getcomputedstyle/flexbox_computedstyle_align-self-invalid.html
		getcomputedstyle/flexbox_computedstyle_align-self-stretch.html
	</wpt>

	<a>Flex items</a> can be aligned in the <a>cross axis</a> of the current line of the flex container,
	similar to 'justify-content' but in the perpendicular direction.
	'align-items' sets the default alignment for all of the flex container's <a lt="flex items">items</a>,
	including anonymous <a>flex items</a>.
	'align-self' allows this default alignment to be overridden for individual <a>flex items</a>.
	(For anonymous flex items,
	'align-self' always matches the value of 'align-items' on their associated flex container.)

	If either of the <a>flex item's</a> cross-axis margins are <a value for=margin>auto</a>,
	'align-self' has no effect.

	Values have the following meanings:

	<dl dfn-type=value dfn-for="align-items, align-self">
		<dt><dfn>auto</dfn>
		<dd>
			Defers <a>cross-axis</a> alignment control
			to the value of 'align-items' on the parent box.
			(This is the initial value of 'align-self'.)

			<wpt>
				align-self-007.html
				align-self-008.html
				align-self-009.html
				align-self-011.html
				align-self-012.html
			</wpt>

		<dt><dfn>flex-start</dfn>
		<dd>
			The <a>cross-start</a> margin edge of the <a>flex item</a>
			is placed flush with the <a>cross-start</a> edge of the line.

			<wpt>
				align-items-002.htm
				align-items-006.html
				align-self-001.html
			</wpt>

		<dt><dfn>flex-end</dfn>
		<dd>
			The <a>cross-end</a> margin edge of the <a>flex item</a>
			is placed flush with the <a>cross-end</a> edge of the line.

			<wpt>
				align-items-003.htm
				align-self-002.html
			</wpt>

		<dt><dfn>center</dfn>
		<dd>
			The <a>flex item</a>’s margin box is centered in the <a>cross axis</a> within the line.
			(If the <a>cross size</a> of the flex line is less than that of the <a>flex item</a>,
			it will overflow equally in both directions.)

			<wpt>
				align-items-001.htm
				align-self-003.html
			</wpt>

		<dt><dfn>baseline</dfn>
		<dd>
			The <a>flex item</a> <dfn dfn id='baseline-participation'>participates in baseline alignment</dfn>:
			all participating <a>flex items</a> on the line
			are aligned such that their baselines align,
			and the item with the largest distance between its baseline and its <a>cross-start</a> margin edge
			is placed flush against the <a>cross-start</a> edge of the line.
			If the item does not have a baseline in the necessary axis,
			then one is <a lt="synthesize baseline">synthesized</a>
			from the <a>flex item</a>’s border box.

			<wpt>
				align-items-004.htm
				align-baseline.html
				dynamic-baseline-change.html
				dynamic-baseline-change-nested.html
			</wpt>

		<dt><dfn>stretch</dfn>
		<dd>
			If the <a>cross size property</a> of the <a>flex item</a> computes to ''width/auto'',
			and neither of the <a>cross-axis</a> margins are ''margin/auto'',
			the <a>flex item</a> is <dfn dfn for=''>stretched</dfn>.
			Its used value is the length necessary to make the <a>cross size</a> of the item's margin box as close to the same size as the line as possible,
			while still respecting the constraints imposed by 'min-height'/'min-width'/'max-height'/'max-width'.

			Note: If the flex container's height is constrained
			this value may cause the contents of the <a>flex item</a>
			to overflow the item.

			The <a>cross-start</a> margin edge of the <a>flex item</a>
			is placed flush with the <a>cross-start</a> edge of the line.

			<wpt>
				align-items-005.htm
				align-self-004.html
				align-self-005.html
				css-flexbox-height-animation-stretch.html
			</wpt>
	</dl>

	<div class='figure'>
		<img src="images/flex-align.svg" width=508 height=377 alt>
		<p class='caption'>An illustration of the five 'align-items' keywords and their effects on a flex container with four colored items.
	</div>

<!--
   ███    ██       ████  ██████   ██    ██          ██████   ███████  ██    ██ ████████ ████████ ██    ██ ████████
  ██ ██   ██        ██  ██    ██  ███   ██         ██    ██ ██     ██ ███   ██    ██    ██       ███   ██    ██
 ██   ██  ██        ██  ██        ████  ██         ██       ██     ██ ████  ██    ██    ██       ████  ██    ██
██     ██ ██        ██  ██   ████ ██ ██ ██ ███████ ██       ██     ██ ██ ██ ██    ██    ██████   ██ ██ ██    ██
█████████ ██        ██  ██    ██  ██  ████         ██       ██     ██ ██  ████    ██    ██       ██  ████    ██
██     ██ ██        ██  ██    ██  ██   ███         ██    ██ ██     ██ ██   ███    ██    ██       ██   ███    ██
██     ██ ████████ ████  ██████   ██    ██          ██████   ███████  ██    ██    ██    ████████ ██    ██    ██
-->

<h3 id='align-content-property'>
Packing Flex Lines: the 'align-content' property</h3>

	<pre class='propdef'>
	Name: align-content
	Value: flex-start | flex-end | center | space-between | space-around | stretch
	Initial: stretch
	Applies to: <a>multi-line</a> <a>flex containers</a>
	Inherited: no
	Computed value: specified keyword
	Animation type: discrete
	</pre>

	The 'align-content' property aligns a flex container's lines within the flex container
	when there is extra space in the <a>cross-axis</a>,
	similar to how 'justify-content' aligns individual items within the <a>main-axis</a>.
	Note, this property has no effect on a <a>single-line</a> <a>flex container</a>.
	Values have the following meanings:

	<dl dfn-type=value dfn-for=align-content>
		<dt><dfn>flex-start</dfn>
		<dd>
			Lines are packed toward the start of the flex container.
			The <a>cross-start</a> edge of the first line in the flex container
			is placed flush with the <a>cross-start</a> edge of the flex container,
			and each subsequent line is placed flush with the preceding line.

		<dt><dfn>flex-end</dfn>
		<dd>
			Lines are packed toward the end of the flex container.
			The <a>cross-end</a> edge of the last line
			is placed flush with the <a>cross-end</a> edge of the flex container,
			and each preceding line is placed flush with the subsequent line.

		<dt><dfn>center</dfn>
		<dd>
			Lines are packed toward the center of the flex container.
			The lines in the flex container are placed flush with each other
			and aligned in the center of the flex container,
			with equal amounts of space
			between the <a>cross-start</a> content edge of the flex container
			and the first line in the flex container,
			and between the <a>cross-end</a> content edge of the flex container
			and the last line in the flex container.
			(If the leftover free-space is negative,
			the lines will overflow equally in both directions.)

		<dt><dfn>space-between</dfn>
		<dd>
			Lines are evenly distributed in the flex container.
			If the leftover free-space is negative
			or there is only a single <a>flex line</a> in the flex container,
			this value falls back to ''safe flex-start''.
			Otherwise,
			the <a>cross-start</a> edge of the first line in the flex container
			is placed flush with the <a>cross-start</a> content edge of the flex container,
			the <a>cross-end</a> edge of the last line in the flex container
			is placed flush with the <a>cross-end</a> content edge of the flex container,
			and the remaining lines in the flex container are distributed
			so that the spacing between any two adjacent lines is the same.

		<dt><dfn>space-around</dfn>
		<dd>
			Lines are evenly distributed in the flex container,
			with half-size spaces on either end.
			If the leftover free-space is negative
			this value falls back to ''safe center''.
			Otherwise, the lines in the flex container are distributed
			such that the spacing between any two adjacent lines is the same,
			and the spacing between the first/last lines and the <a>flex container</a> edges
			is half the size of the spacing between <a>flex lines</a>.

		<dt><dfn>stretch</dfn>
		<dd>
			Lines stretch to take up the remaining space.
			If the leftover free-space is negative,
			this value falls back to ''align-content/flex-start''.
			Otherwise,
			the free-space is split equally between all of the lines,
			increasing their cross size.
	</dl>

	Note: Only <a>multi-line</a> <a>flex containers</a>
	ever have free space in the <a>cross-axis</a> for lines to be aligned in,
	because in a <a>single-line</a> flex container
	the sole line automatically stretches to fill the space.

	<div class="figure">
		<img src="images/align-content-example.svg" width=612 height=508 alt>
		<p class='caption'>
			An illustration of the 'align-content' keywords and their effects on a <a>multi-line</a> flex container.
	</div>

	<wpt>
		align-content_center.html
		align-content_flex-end.html
		align-content_flex-start.html
		align-content-horiz-001a.html
		align-content-horiz-001b.html
		align-content-horiz-002.html
		align-content-stretch-rounding.html
		align-content_space-around.html
		align-content_space-between.html
		align-content_stretch.html
		align-content-vert-001a.html
		align-content-vert-001b.html
		align-content-vert-002.html
		align-content-wmvert-001.html
		align-content-wrap-001.html
		align-content-wrap-002.html
		align-content-wrap-003.html
		align-content-wrap-004.html
		align-content-wrap-005.html
		flex-align-content-center.html
		flex-align-content-end.html
		flex-align-content-space-around.html
		flex-align-content-space-between.html
		flex-align-content-start.html
		flexbox_align-content-center.html
		flexbox_align-content-flexend.html
		flexbox_align-content-flexstart.html
		flexbox_align-content-spacearound.html
		flexbox_align-content-spacebetween.html
		flexbox_align-content-stretch-2.html
		flexbox_align-content-stretch.html
		getcomputedstyle/flexbox_computedstyle_align-content-center.html
		getcomputedstyle/flexbox_computedstyle_align-content-flex-end.html
		getcomputedstyle/flexbox_computedstyle_align-content-flex-start.html
		getcomputedstyle/flexbox_computedstyle_align-content-space-around.html
		getcomputedstyle/flexbox_computedstyle_align-content-space-between.html
		align-content-rounding.html
	</wpt>

<!--
████████     ███     ██████  ████████ ██       ████ ██    ██ ████████  ██████
██     ██   ██ ██   ██    ██ ██       ██        ██  ███   ██ ██       ██    ██
██     ██  ██   ██  ██       ██       ██        ██  ████  ██ ██       ██
████████  ██     ██  ██████  ██████   ██        ██  ██ ██ ██ ██████    ██████
██     ██ █████████       ██ ██       ██        ██  ██  ████ ██             ██
██     ██ ██     ██ ██    ██ ██       ██        ██  ██   ███ ██       ██    ██
████████  ██     ██  ██████  ████████ ████████ ████ ██    ██ ████████  ██████
-->

<h3 id="flex-baselines">
Flex Container Baselines</h3>

	In order for a <a>flex container</a> to itself <a href="#baseline-participation">participate in baseline alignment</a>
	(e.g. when the <a>flex container</a> is itself a <a>flex item</a> in an outer <a>flex container</a>),
	it needs to submit the position of the baselines that will best represent its contents.
	To this end,
	the baselines of a flex container are determined as follows
	(after reordering with 'order',
	and taking 'flex-direction' into account):

	<dl>
		<dt>first/last <dfn export id="main-axis-baseline"
		    lt="main-axis baseline set|first main-axis baseline set|last main-axis baseline set">
		    main-axis baseline set</dfn>
		<dd>
			When the <a>inline axis</a> of the <a>flex container</a>
			matches its <a>main axis</a>,
			its baselines are determined as follows:

			1. If any of the [=flex items=] on the flex container's [=startmost=] [=flex line=]
				participate in first [=baseline alignment=] along the [=main axis=],
				<a lt="generate baselines">generate</a> a [=baseline set=] from their shared [=alignment baseline=]
				and the [=flex container's=] [=first available font=].

			2. Otherwise, if any of the [=flex items=] on the flex container's [=startmost=] [=flex line=]
				participate in last [=baseline alignment=] along the [=main axis=],
				<a lt="generate baselines">generate</a> a [=baseline set=] from their shared [=alignment baseline=]
				and the [=flex container's=] [=first available font=].

			3. Otherwise, if any [=flex items=] in the [=startmost=] [=flex line=]
				have a [=baseline set=] along the [=main axis=],
				take the [=baseline set=] from the first such [=flex item=]
				in [=order-modified document order=].

			4. Otherwise, if there are any [=flex items=] at all,
				<a lt="synthesize baselines">synthesize</a> a [=baseline set=]
				from the [=startmost=] [=flex item=] on the [=startmost=] line.

			5. Otherwise, the [=flex container=] has no first [=main-axis=] <a>baseline set</a>.
				(One is <a lt="synthesize baselines">synthesized</a>
				from the [=flex container=] itself if needed,
				according to the rules of its <a>alignment context</a>.)

			Last baselines are analogous
			(with “first”/“last” and “start”/“end” inverted).

		<dt>first/last <dfn export id="cross-axis-baseline"
			lt="cross-axis baseline set|first cross-axis baseline set|last cross-axis baseline set">
			cross-axis baseline set</dfn>
		<dd>
			When the <a>inline axis</a> of the <a>flex container</a>
			matches its <a>cross axis</a>,
			its baselines are determined as follows:

			1. If the flex container has at least one <a>flex item</a>,
				the flex container's first/last <a>cross-axis baseline set</a>
				is <a lt="generate baselines">generated</a> from
				the <a>alignment baseline</a> of the [=startmost=]/[=endmost=] <a>flex item</a>.
				(If that item has no <a>alignment baseline</a>
				parallel to the flex container's <a>cross axis</a>,
				then one is first <a lt="synthesized baseline">synthesized</a>
				from its border edges.)

			2. Otherwise, the flex container has no first/last cross-axis <a>baseline set</a>,
				and one is <a lt="synthesize baselines">synthesized</a> if needed
				according to the rules of its <a>alignment context</a>.

	</dl>

	When calculating the baseline according to the above rules,
	if the box contributing a baseline has an 'overflow' value that allows scrolling,
	the box must be treated as being in its initial scroll position
	for the purpose of determining its baseline.

	When <a href="https://www.w3.org/TR/CSS2/tables.html#height-layout">determining the baseline of a table cell</a>,
	a flex container provides a baseline just as a line box or table-row does. [[!CSS2]]

	See [[css-writing-modes-3#intro-baselines]]
	and [[css-align-3#baseline-rules]]
	for more information on baselines.

	<wpt>
		alignment/flex-align-baseline-001.html
		alignment/flex-align-baseline-002.html
		alignment/flex-align-baseline-003.html
		alignment/flex-align-baseline-004.html
		alignment/flex-align-baseline-005.html
		alignment/flex-align-baseline-006.html
		alignment/flex-align-baseline-007.html
		alignment/flex-align-baseline-column-rtl-direction.html
		alignment/flex-align-baseline-column-vert-lr-rtl-wrap-reverse.html
		alignment/flex-align-baseline-column-vert-rl-rtl-wrap-reverse.html
		alignment/flex-align-baseline-fieldset-001.html
		alignment/flex-align-baseline-fieldset-002.html
		alignment/flex-align-baseline-fieldset-003.html
		alignment/flex-align-baseline-flex-001.html
		alignment/flex-align-baseline-flex-002.html
		alignment/flex-align-baseline-flex-003.html
		alignment/flex-align-baseline-flex-004.html
		alignment/flex-align-baseline-grid-001.html
		alignment/flex-align-baseline-grid-002.html
		alignment/flex-align-baseline-grid-003.html
		alignment/flex-align-baseline-multicol-001.html
		alignment/flex-align-baseline-multicol-002.html
		alignment/flex-align-baseline-multicol-003.html
		alignment/flex-align-baseline-overflow-001.html
		alignment/flex-align-baseline-overflow-002.html
		alignment/flex-align-baseline-overflow-003.html
		alignment/flex-align-baseline-table-001.html
		alignment/flex-align-baseline-table-002.html
		alignment/flex-align-baseline-table-003.html
		flex-baseline-overflow-hidden.html
		flex-order-last-baseline.html
		flex-order-last-baseline-multiple.html
		flex-order-wrap-reverse-baseline.html
		flexbox-baseline-align-self-baseline-horiz-001.html
		flexbox-baseline-align-self-baseline-vert-001.html
		flexbox-baseline-empty-001a.html
		flexbox-baseline-empty-001b.html
		flexbox-baseline-multi-item-horiz-001a.html
		flexbox-baseline-multi-item-horiz-001b.html
		flexbox-baseline-multi-item-vert-001a.html
		flexbox-baseline-multi-item-vert-001b.html
		flexbox-baseline-multi-line-horiz-001.html
		flexbox-baseline-multi-line-horiz-002.html
		flexbox-baseline-multi-line-horiz-003.html
		flexbox-baseline-multi-line-horiz-004.html
		flexbox-baseline-multi-line-vert-001.html
		flexbox-baseline-multi-line-vert-002.html
		flexbox-baseline-nested-001.html
		flexbox-baseline-single-item-001a.html
		flexbox-baseline-single-item-001b.html
	</wpt>

<!--
██          ███    ██    ██  ███████  ██     ██ ████████
██         ██ ██    ██  ██  ██     ██ ██     ██    ██
██        ██   ██    ████   ██     ██ ██     ██    ██
██       ██     ██    ██    ██     ██ ██     ██    ██
██       █████████    ██    ██     ██ ██     ██    ██
██       ██     ██    ██    ██     ██ ██     ██    ██
████████ ██     ██    ██     ███████   ███████     ██
-->

<h2 id='layout-algorithm'>
Flex Layout Algorithm</h2>

	This section contains normative algorithms
	detailing the exact layout behavior of a flex container and its contents.
	The algorithms here are written 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.

	Note: 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.

	The following sections define the algorithm for laying out a flex container and its contents.

	Note: Flex layout works with the <a>flex items</a> in <a>order-modified document order</a>,
	not their original document order.

	<wpt>
		flexbox-basic-block-horiz-001v.xhtml
		flexbox-basic-block-horiz-001.xhtml
		flexbox-basic-block-vert-001v.xhtml
		flexbox-basic-block-vert-001.xhtml
		flexbox-basic-canvas-horiz-001v.xhtml
		flexbox-basic-canvas-horiz-001.xhtml
		flexbox-basic-canvas-vert-001v.xhtml
		flexbox-basic-canvas-vert-001.xhtml
		flexbox-basic-fieldset-horiz-001.xhtml
		flexbox-basic-fieldset-vert-001.xhtml
		flexbox-basic-iframe-horiz-001.xhtml
		flexbox-basic-iframe-vert-001.xhtml
		flexbox-basic-img-horiz-001.xhtml
		flexbox-basic-img-vert-001.xhtml
		flexbox-basic-textarea-horiz-001.xhtml
		flexbox-basic-textarea-vert-001.xhtml
		flexbox-basic-video-horiz-001.xhtml
		flexbox-basic-video-vert-001.xhtml
		flexbox-dyn-resize-001.html
		flexbox-mbp-horiz-001-rtl.xhtml
		flexbox-mbp-horiz-001.xhtml
		flexbox-mbp-horiz-002a.xhtml
		flexbox-mbp-horiz-002b.xhtml
		flexbox-mbp-horiz-002v.xhtml
		flexbox-mbp-horiz-003-reverse.xhtml
		flexbox-mbp-horiz-003v.xhtml
		flexbox-mbp-horiz-003.xhtml
		flexbox-mbp-horiz-004.xhtml
		flexbox-sizing-horiz-001.xhtml
		flexbox-sizing-horiz-002.xhtml
		flexbox-sizing-vert-001.xhtml
		flexbox-sizing-vert-002.xhtml
		percentage-max-height-001.html
		percentage-max-height-002.html
		percentage-max-height-003.html
		percentage-max-height-004.html
		percentage-max-height-005.html
		percent-height-flex-items-cross-sizes-with-mutations.html
		table-as-item-auto-min-width.html
		table-as-item-change-cell.html
		table-as-item-fixed-min-width-2.html
		table-as-item-fixed-min-width-3.html
		table-as-item-fixed-min-width.html
		table-as-item-narrow-content-2.html
		table-as-item-narrow-content.html
		table-as-item-specified-height.html
		table-as-item-specified-width.html
		table-as-item-specified-width-vertical.html
	</wpt>

<h3 id='box-manip'>
Initial Setup</h3>

	<ol start=1 class="layout-start">
		<li id='algo-anon-box'>
			<strong>Generate anonymous flex items</strong>
			as described in [[#flex-items]].
	</ol>

<h3 id='line-sizing'>
Line Length Determination</h3>

	<ol class=continue>
		<li id='algo-available'>
			<strong>Determine the available main and cross space for the flex items.</strong>
			For each dimension,
			if that dimension of the <a>flex container</a>’s content box is a <a>definite size</a>, use that;
			if that dimension of the <a>flex container</a> is being sized under a <a lt="min-content constraint">min</a> or <a>max-content constraint</a>,
			the available space in that dimension is that constraint;
			otherwise, subtract the <a>flex container</a>’s margin, border, and padding
			from the space available to the flex container in that dimension
			and use that value.
			<span class='note'>This might result in an infinite value.</span>
			<!-- Maybe???
			For this purpose,
			the block axis of a block container(?)
			always provides infinite available space.
			-->

			<div class='example'>
				<p>For example, the <a>available space</a> to a flex item in a
					<a href="https://www.w3.org/TR/CSS2/visuren.html#floats">floated</a> <a value for=width>auto</a>-sized <a>flex container</a> is:
				<ul>
					<li>the width of the <a>flex container</a>’s containing block minus the <a>flex container</a>’s margin, border, and padding in the horizontal dimension
					<li>infinite in the vertical dimension
				</ul>
			</div>

		<li id='algo-main-item'>
			<strong>Determine the <dfn>flex base size</dfn> and <dfn>hypothetical main size</dfn> of each item:</strong>

			<wpt>
				flex-item-percentage-height-img-001.html
				image-as-flexitem-size-001.html
				image-as-flexitem-size-001v.html
				image-as-flexitem-size-002.html
				image-as-flexitem-size-002v.html
				image-as-flexitem-size-003.html
				image-as-flexitem-size-003v.html
				image-as-flexitem-size-004.html
				image-as-flexitem-size-004v.html
				image-as-flexitem-size-005.html
				image-as-flexitem-size-005v.html
				image-as-flexitem-size-006.html
				image-as-flexitem-size-006v.html
				image-as-flexitem-size-007.html
				image-as-flexitem-size-007v.html
				item-with-table-with-infinite-max-intrinsic-width.html
				multiline-min-max.html
				orthogonal-writing-modes-and-intrinsic-sizing.html
				svg-root-as-flex-item-001.html
				svg-root-as-flex-item-002.html
				svg-root-as-flex-item-003.html
				svg-root-as-flex-item-004.html
				svg-root-as-flex-item-005.html
				svg-root-as-flex-item-006.html
				table-as-item-min-height-1.html
				table-as-item-wide-content.html
				table-with-infinite-max-intrinsic-width.html
			</wpt>

			<ol type=A>
				<li>
					If the item has a <a>definite</a> used <a>flex basis</a>,
					that's the <a>flex base size</a>.

				<li>
					If the flex item has ...
					<ul>
						<li>a [=preferred aspect ratio=],
						<li>a used <a>flex basis</a> of ''content'', and
						<li>a <a>definite</a> <a>cross size</a>,
					</ul>
					then the <a>flex base size</a> is calculated from
					its <a lt="used value">used</a> <a>cross size</a>
					and the <a>flex item</a>’s aspect ratio.

				<li>
					If the used <a>flex basis</a> is ''content'' or depends on its <a>available space</a>,
					and the flex container is being sized under a min-content or max-content constraint
					(e.g. when performing <a href="https://www.w3.org/TR/CSS2/tables.html#auto-table-layout">automatic table layout</a> [[!CSS2]]),
					size the item under that constraint.
					The <a>flex base size</a> is the item's resulting <a>main size</a>.

				<li>
					Otherwise,
					if the used <a>flex basis</a> is ''content'' or depends on its <a>available space</a>,
					the available main size is infinite,
					and the flex item's inline axis is parallel to the main axis,
					lay the item out using
					<a href="https://www.w3.org/TR/css3-writing-modes/#orthogonal-flows">the rules for a box in an orthogonal flow</a> [[!CSS3-WRITING-MODES]].
					The <a>flex base size</a> is the item's max-content <a>main size</a>.

					Note: This case occurs, for example,
					in an English document (horizontal <a>writing mode</a>)
					containing a column flex container
					containing a vertical Japanese (vertical <a>writing mode</a>) <a>flex item</a>.

				<li>
					Otherwise,
					size the item into the <a>available space</a>
					using its used <a>flex basis</a> in place of its <a>main size</a>,
					treating a value of ''content'' as ''width/max-content''.
					If a <a>cross size</a> is needed to determine the <a>main size</a>
					(e.g. when the <a>flex item</a>’s <a>main size</a> is in its block axis,
					or when it has a [=preferred aspect ratio=])
					and the <a>flex item</a>’s cross size is ''auto'' and not <a>definite</a>,
					in this calculation use ''width/fit-content'' as the <a>flex item</a>’s <a>cross size</a>.
					The <a>flex base size</a> is the item's resulting <a>main size</a>.

				<wpt>
					css-flexbox-img-expand-evenly.html
					fit-content-item-001.html
					fit-content-item-002.html
					fit-content-item-003.html
					fit-content-item-004.html
					flexbox-vert-lr-with-img.html
					flex-container-max-content-001.html
					flex-container-min-content-001.html
					flex-height-min-content.html
				</wpt>
			</ol>

			When determining the <a>flex base size</a>,
			the item’s min and max <a>main sizes</a> are ignored
			(no clamping occurs).
			Furthermore, the sizing calculations that floor the content box size at zero
			when applying 'box-sizing' are also ignored.
			(For example, an item with a specified size of zero,
			positive padding, and ''box-sizing: border-box''
			will have an outer <a>flex base size</a> of zero--
			and hence a negative inner <a>flex base size</a>.)

			The <a>hypothetical main size</a> is the item's <a>flex base size</a>
			clamped according to its <a lt="used value">used</a> min and max <a>main sizes</a>
			(and flooring the content box size at zero).

			<wpt>
				text-as-flexitem-size-001.html
			</wpt>

		<li id='algo-main-container'>
			<strong>Determine the <a>main size</a> of the flex container</strong>
			using the rules of the formatting context in which it participates.

			<div class=note>
				The [=automatic block size=] of a [=block-level=] [=flex container=]
				is its [=max-content size=].

				The Block Layout spec should define this equivalency, but it doesn't exist yet.
			</div>
	</ol>

<h3 id='main-sizing'>
Main Size Determination</h3>

	<ol class=continue>
		<li id='algo-line-break'>
			<strong>Collect flex items into flex lines:</strong>

			<ul>
				<li>
					If the flex container is <a>single-line</a>,
					collect all the flex items into a single flex line.

				<li>
					Otherwise,
					starting from the first uncollected item,
					collect consecutive items one by one
					until the first time that the <em>next</em> collected item
					would not fit into the flex container's [=inner size|inner=] main size
					(or until a forced break is encountered,
					see [[#pagination]]).
					If the very first uncollected item wouldn't fit,
					collect just it into the line.

					<p>
						For this step,
						the size of a flex item is its [=outer size|outer=] <a>hypothetical main size</a>.
						<span class=note>(Note: This can be negative.)</span>

					<p>
						Repeat until all flex items have been collected into flex lines.

					<p class='note'>
						Note that the "collect as many" line will collect zero-sized flex items
						onto the end of the previous line
						even if the last non-zero item exactly "filled up" the line.
			</ul>

		<li id='algo-flex'>
			<strong><a href='#resolve-flexible-lengths'>Resolve the flexible lengths</a></strong> of all the flex items
			to find their used <a>main size</a>. See [[#resolve-flexible-lengths]].
	</ol>

	<wpt>
		flexbox_quirks_body.html
		ortho-table-item-001.html
		percentage-heights-000.html
		percentage-heights-001.html
		percentage-heights-002.html
		percentage-heights-003.html
		percentage-heights-004.html
		percentage-heights-005.html
		percentage-heights-006.html
		percentage-heights-007.html
		percentage-heights-008.html
		percentage-heights-009.html
		percentage-heights-010.html
		percentage-heights-011.html
		percentage-heights-012.html
		percentage-heights-013.html
		percentage-heights-014.html
		percentage-heights-015.html
		percentage-heights-016.html
		percentage-heights-017.html
		percentage-heights-018.html
		percentage-heights-019.html
		percentage-heights-020.html
		percentage-heights-021.html
		percentage-heights-022.html
		percentage-heights-023.html
	</wpt>

<h3 id='cross-sizing'>
Cross Size Determination</h3>

	<ol class=continue>
		<li id='algo-cross-item'>
			<strong>Determine the <dfn>hypothetical cross size</dfn> of each item</strong>
			by performing layout as if it were an [=in-flow=] [=block-level box=]
			with the used [=main size=] and the given available space,
			treating <a value for=width>auto</a> as ''fit-content''.

			<wpt>
				canvas-contain-size.html
				inline-flex-column-image-load.html
			</wpt>

		<li id='algo-cross-line'>
			<strong>Calculate the cross size of each flex line.</strong>

			<p>
				If the flex container is <a>single-line</a>
				and has a <a>definite</a> <a>cross size</a>,
				the <a>cross size</a> of the <a>flex line</a>
				is the <a>flex container</a>'s inner <a>cross size</a>.

			<p>
				Otherwise,
				for each flex line:

			<ol>
				<li>
					Collect all the flex items whose inline-axis is parallel to the main-axis,
					whose 'align-self' is ''align-self/baseline'',
					and whose cross-axis margins are both non-<a value for=margin>auto</a>.
					Find the largest of the distances between each item's baseline and its hypothetical outer cross-start edge,
					and the largest of the distances between each item's baseline and its hypothetical outer cross-end edge,
					and sum these two values.

				<li>
					Among all the items not collected by the previous step,
					find the largest outer <a>hypothetical cross size</a>.

				<li>
					The used <a>cross size</a> of the <a>flex line</a> is the largest of the numbers found in the previous two steps and zero.

					If the flex container is <a>single-line</a>,
					then clamp the line's cross-size to be within
					the container's computed min and max cross sizes.
					<span class='note'>Note that if CSS 2.1's definition of min/max-width/height applied more generally,
					this behavior would fall out automatically.</span>
			</ol>

			<wpt>
				flexbox-single-line-clamp-1.html
				flexbox-single-line-clamp-2.html
				flexbox-single-line-clamp-3.html
				flex-item-contains-size-layout-001.html
				flex-item-contains-strict.html
				layout-algorithm_algo-cross-line-001.html
				layout-algorithm_algo-cross-line-002.html
			</wpt>


		<li id='algo-line-stretch'>
			<strong>Handle 'align-content: stretch'.</strong>
			If the flex container has a <a>definite</a> <a>cross size</a>,
			'align-content' is <a value for=align-content>stretch</a>,
			and the sum of the flex lines' cross sizes is less than the flex container's inner cross size,
			increase the cross size of each flex line by equal amounts
			such that the sum of their cross sizes exactly equals the flex container's inner cross size.

		<li id='algo-visibility'>
			<strong>Collapse ''visibility:collapse'' items.</strong>
			If any flex items have ''visibility: collapse'',
			note the <a>cross size</a> of the line they're in as the item's |strut size|,
			and restart layout from the beginning.

			In this second layout round,
			when <a href="#algo-line-break">collecting items into lines</a>,
			treat the collapsed items as having zero <a>main size</a>.
			For the rest of the algorithm following that step,
			ignore the collapsed items entirely
			(as if they were ''display:none'')
			except that after <a href="#algo-cross-line">calculating the cross size of the lines</a>,
			if any line's cross size is less than
			the largest <var>strut size</var>
			among all the collapsed items in the line,
			set its cross size to that <var>strut size</var>.

			Skip this step in the second layout round.

			<wpt>
				flexbox-collapsed-item-baseline-001.html
				flexbox-collapsed-item-horiz-001.html
				flexbox-collapsed-item-horiz-002.html
				flexbox-collapsed-item-horiz-003.html
			</wpt>

		<li id='algo-stretch'>
			<strong>Determine the used cross size of each flex item.</strong>
			If a flex item's [=cross size=] depends on the available space
			in the [=cross axis=],
			recalculate its cross size using the [=flex line's=] [=cross size=]
			(rather than the [=flex container's=]) as the available space.
			Otherwise,
			the used cross size is the item's <a>hypothetical cross size</a>.

			If the flex item's [=cross size=] changed as a result,
			redo layout for its contents,
			treating this used size as its definite cross size
			so that percentage-sized children can be resolved.

			<wpt>
				table-as-item-cross-size.html
			</wpt>

			Note: This step does not affect the <a>main size</a> of the flex item,
			even if it has a [=preferred aspect ratio=].
	</ol>

	<wpt>
		flex-item-and-percentage-abspos.html
	</wpt>

<h3 id='main-alignment'>
Main-Axis Alignment</h3>

	<ol class=continue>
		<li id='algo-main-align'>
			<strong>Distribute any remaining free space.</strong>
			For each flex line:

			<ol>
				<li>
					If the remaining free space is positive
					and at least one main-axis margin on this line is <a value for=margin>auto</a>,
					distribute the free space equally among these margins.
					Otherwise, set all <a value for=margin>auto</a> margins to zero.

				<li>
					Align the items along the main-axis per 'justify-content'.
			</ol>
	</ol>

<h3 id='cross-alignment'>
Cross-Axis Alignment</h3>

	<ol class=continue>
		<li id='algo-cross-margins'>
			<strong>Resolve cross-axis <a value for=margin>auto</a> margins.</strong>
			If a flex item has <a value for=margin>auto</a> cross-axis margins:

			<ul>
				<li>
					If its outer cross size
					(treating those <a value for=margin>auto</a> margins as zero)
					is less than the cross size of its flex line,
					distribute the difference in those sizes equally
					to the <a value for=margin>auto</a> margins.
				<li>
					Otherwise,
					if the <a>block-start</a> or <a>inline-start</a> margin (whichever is in the cross axis)
					is <a value for=margin>auto</a>, set it to zero.
					Set the opposite margin so that the outer cross size of the item
					equals the cross size of its flex line.
			</ul>


		<li id='algo-cross-align'>
			<strong>Align all flex items along the cross-axis</strong> per 'align-self',
			if neither of the item's cross-axis margins are <a value for=margin>auto</a>.

		<li id='algo-cross-container'>
			<strong>Determine the flex container's used cross size</strong>
			using the rules of the [=formatting context=] in which it participates.
			If a content-based [=cross size=] is needed,
			use the sum of the [=flex lines=]' [=cross sizes=].

		<li id='algo-line-align'>
			<strong>Align all flex lines</strong> per 'align-content'.
	</ol>

<h3 id='resolve-flexible-lengths'>
Resolving Flexible Lengths</h3>

	<p>
		To resolve the flexible lengths of the items within a flex line:

	<ol>
		<li>
			<strong>Determine the used flex factor</strong>.
			Sum the outer hypothetical main sizes of all items on the line.
			If the sum is less than the flex container's inner <a>main size</a>,
			use the flex grow factor for the rest of this algorithm;
			otherwise, use the flex shrink factor.

		<li>
			Each item in the flex line has a <dfn>target main size</dfn>,
			initially set to its [=flex base size=].
			Each item is initially <i>unfrozen</i>
			and may become <i>frozen</i>.

			Note: An item’s [=target main size=] doesn’t change after freezing.

		<li>
			<strong>Size inflexible items.</strong>
			Freeze,
			setting its [=target main size=]
			to its <a>hypothetical main size</a>&hellip;
			<ul>
				<li>
					any item that has a flex factor of zero

				<li>
					if using the <a>flex grow factor</a>:
					any item that has a <a>flex base size</a> greater than its <a>hypothetical main size</a>

				<li>
					if using the <a>flex shrink factor</a>:
					any item that has a <a>flex base size</a> smaller than its <a>hypothetical main size</a>
			</ul>

		<li>
			<strong>Calculate <dfn>initial free space</dfn>.</strong>
			Sum the outer sizes of all items on the line,
			and subtract this from the flex container's inner <a>main size</a>.
			For frozen items, use their outer <a>target main size</a>;
			for other items, use their outer <a>flex base size</a>.

		<li>
			Loop:

			<ol type=a>
				<li>
					<strong>Check for flexible items.</strong>
					If all the flex items on the line are frozen, exit this loop.

				<li>
					<strong>Calculate the <dfn>remaining free space</dfn></strong>
					as for <a>initial free space</a>, above.
					If the sum of the unfrozen flex items’ flex factors is less than one,
					multiply the <a>initial free space</a> by this sum.
					If the magnitude of this value is less than the magnitude of the <a>remaining free space</a>,
					use this as the <a>remaining free space</a>.

				<li>
					If the [=remaining free space=] is non-zero,
					<strong>distribute it proportional to the flex factors</strong>:

					<dl>
						<dt>If using the <a>flex grow factor</a>
						<dd>
							For every unfrozen item on the line,
							find the ratio of the item's flex grow factor
							to the sum of the flex grow factors of all unfrozen items on the line.
							Set the item's <a>target main size</a> to its <a>flex base size</a>
							plus a fraction of the <a>remaining free space</a> proportional to the ratio.

						<dt>If using the <a>flex shrink factor</a>
						<dd>
							For every unfrozen item on the line,
							multiply its flex shrink factor by its inner <a>flex base size</a>,
							and note this as its <dfn>scaled flex shrink factor</dfn>.
							Find the ratio of the item's <a>scaled flex shrink factor</a>
							to the sum of the <a>scaled flex shrink factors</a> of all unfrozen items on the line.
							Set the item's <a>target main size</a> to its <a>flex base size</a>
							minus a fraction of the absolute value of the <a>remaining free space</a> proportional to the ratio.
							<span class='note'>Note this may result in a negative inner <a>main size</a>;
							it will be corrected in the next step.</span>
					</dl>

				<li>
					<strong>Fix min/max violations.</strong>
					Clamp each non-frozen item's <a>target main size</a> by
					its <a lt="used value">used</a> min and max <a>main sizes</a>
					and floor its content-box size at zero.
					If the item's <a>target main size</a> was made smaller by this,
					it's a max violation.
					If the item's <a>target main size</a> was made larger by this,
					it's a min violation.

				<li>
					<strong>Freeze over-flexed items.</strong>
					The total violation is the sum of the adjustments from the previous step
					<code>∑(clamped size - unclamped size)</code>.
					If the total violation is:

					<dl>
						<dt>Zero
						<dd>
							Freeze all items.

						<dt>Positive
						<dd>
							Freeze all the items with min violations.

						<dt>Negative
						<dd>
							Freeze all the items with max violations.
					</dl>

					Note: This freezes at least one item,
					ensuring that the loop makes progress and eventually terminates.

				<li>
					Return to the start of this loop.
			</ol>

		<li>
			Set each item’s used <a>main size</a> to its <a>target main size</a>.
	</ol>

	<wpt>
		item-with-max-height-and-scrollbar.html
		item-with-max-height-and-scrollbar.html
		max-width-violation.html
		relayout-image-load.html
		table-as-item-inflexible-in-column-1.html
		table-as-item-inflexible-in-column-2.html
		table-as-item-inflexible-in-row-1.html
		table-as-item-inflexible-in-row-2.html
		total-min-max-violation-zero.html
	</wpt>

<!--
████████  ████████ ████████ ████ ██    ██ ████ ████████ ████████
██     ██ ██       ██        ██  ███   ██  ██     ██    ██
██     ██ ██       ██        ██  ████  ██  ██     ██    ██
██     ██ ██████   ██████    ██  ██ ██ ██  ██     ██    ██████
██     ██ ██       ██        ██  ██  ████  ██     ██    ██
██     ██ ██       ██        ██  ██   ███  ██     ██    ██
████████  ████████ ██       ████ ██    ██ ████    ██    ████████
-->

<h3 id='definite-sizes'>
Definite and Indefinite Sizes</h3>

	Although CSS Sizing [[!CSS-SIZING-3]] defines <a spec=css-sizing>definite</a> and <a spec=css-sizing>indefinite</a> lengths,
	Flexbox has several additional cases where a length can be considered <dfn noexport lt="definite|definite size|indefinite|indefinite size">definite</dfn>:

	1. If the [=flex container=] has a [=definite=] [=main size=],
		then the post-flexing [=main sizes=]
		of its [=flex items=]
		are treated as [=definite=].

	2. If a [=flex item’s=] [=flex basis=] is [=definite=],
		then its post-flexing [=main size=] is also [=definite=].

	3. If a <a>single-line</a> <a>flex container</a> has a definite <a>cross size</a>,
		the  [=automatic size|automatic=] [=preferred size|preferred=] [=outer size|outer=] [=cross size=]
		of any <a>stretched</a> <a>flex items</a>
		is the flex container's inner <a>cross size</a>
		(clamped to the <a>flex item</a>’s min and max <a>cross size</a>)
		and is considered <a>definite</a>.

	4. Once the cross size of a flex line has been determined,
		the cross sizes of items in auto-sized flex containers
		are also considered definite for the purpose of layout;
		see <a href="#algo-stretch">step 11</a>.

	<wpt>
		flexbox-definite-cross-size-constrained-percentage.html
		flexbox-definite-sizes-001.html
		flexbox-definite-sizes-002.html
		flexbox-definite-sizes-003.html
		flexbox-definite-sizes-004.html
		flexbox-definite-sizes-005.html
		flexbox-definite-sizes-006.html
		height-percentage-with-dynamic-container-size.html
		percentage-size-quirks-003.html
		percentage-size-quirks-004.html
		percentage-size-quirks-005.html
		percentage-widths-001.html
		position-fixed-001.html
		position-relative-percentage-top-004.html
		position-relative-stretch-height-001.html
		stretch-obeys-min-max-001.html
		stretch-obeys-min-max-002.html
		stretch-obeys-min-max-003.html
	</wpt>

	Note: This means that within [=flex layout=],
	“definite” sizes can require performing layout.
	This was done to allow percentages inside of [=flex items=]
	to resolve where authors expected them to resolve.


<!--
████ ██    ██ ████████ ████████         ██████  ████ ████████ ████████  ██████
 ██  ███   ██    ██    ██     ██       ██    ██  ██       ██  ██       ██    ██
 ██  ████  ██    ██    ██     ██       ██        ██      ██   ██       ██
 ██  ██ ██ ██    ██    ████████         ██████   ██     ██    ██████    ██████
 ██  ██  ████    ██    ██   ██               ██  ██    ██     ██             ██
 ██  ██   ███    ██    ██    ██        ██    ██  ██   ██      ██       ██    ██
████ ██    ██    ██    ██     ██        ██████  ████ ████████ ████████  ██████
-->

<h3 id='intrinsic-sizes'>
Intrinsic Sizes</h3>

	The <a>intrinsic sizing</a> of a <a>flex container</a> is used
	to produce various types of content-based automatic sizing,
	such as shrink-to-fit logical widths (which use the ''fit-content'' formula)
	and content-based logical heights (which use the <a>max-content size</a>).
	For these computations, <a value for=margin>auto</a> margins on flex items are treated as ''0''.

	See [[!CSS-SIZING-3]] for a definition of the terms in this section.

	<wpt>
		flexbox-gap-position-absolute.html
		gap-001-lr.html
		gap-001-ltr.html
		gap-001-rl.html
		gap-001-rtl.html
		gap-002-lr.html
		gap-002-ltr.html
		gap-002-rl.html
		gap-002-rtl.html
		gap-003-lr.html
		gap-003-ltr.html
		gap-003-rl.html
		gap-003-rtl.html
		gap-004-lr.html
		gap-004-ltr.html
		gap-004-rl.html
		gap-004-rtl.html
		gap-005-lr.html
		gap-005-ltr.html
		gap-005-rl.html
		gap-005-rtl.html
		gap-006-lr.html
		gap-006-ltr.html
		gap-006-rl.html
		gap-006-rtl.html
		gap-007-lr.html
		gap-007-ltr.html
		gap-007-rl.html
		gap-007-rtl.html
		gap-008-ltr.html
		gap-009-ltr.html
		gap-010-ltr.html
		gap-011.html
		gap-012.html
		gap-013.html
		gap-014.html
		gap-015.html
		gap-016.html
		gap-017.html
		gap-018.html
		gap-019.html
		gap-020.html
		gap-021.html
		intrinsic-size/auto-min-size-001.html
		intrinsic-size/col-wrap-001.html
		intrinsic-size/col-wrap-002.html
		intrinsic-size/col-wrap-003.html
		intrinsic-size/col-wrap-004.html
		intrinsic-size/col-wrap-005.html
		intrinsic-size/col-wrap-006.html
		intrinsic-size/col-wrap-007.html
		intrinsic-size/col-wrap-008.html
		intrinsic-size/col-wrap-009.html
		intrinsic-size/col-wrap-010.html
		intrinsic-size/col-wrap-011.html
		intrinsic-size/col-wrap-012.html
		intrinsic-size/col-wrap-013.html
		intrinsic-size/col-wrap-014.html
		intrinsic-size/col-wrap-015.html
		intrinsic-size/col-wrap-016.html
		intrinsic-size/col-wrap-017.html
		intrinsic-size/col-wrap-018.html
		intrinsic-size/col-wrap-019.html
		intrinsic-size/col-wrap-020.html
		intrinsic-size/col-wrap-crash.html
		intrinsic-size/row-001.html
		intrinsic-size/row-002.html
		intrinsic-size/row-003.html
		intrinsic-size/row-004.html
		intrinsic-size/row-005.html
		intrinsic-size/row-006.html
		intrinsic-size/row-007.html
		intrinsic-size/row-008.html
		intrinsic-size/row-compat-001.html
		intrinsic-size/row-use-cases-001.html
		intrinsic-size/row-wrap-001.html
		multiline-shrink-to-fit.html
		svg-no-natural-size-grandchild.html
		relayout-intrinsic-block-size.html
	</wpt>

<h4 id='intrinsic-main-sizes'>
Flex Container Intrinsic Main Sizes</h4>

	The <strong><a>max-content</a> <a>main size</a> of a <a>flex container</a></strong>
	is, theoretically, the smallest size the <a>flex container</a> can take
	such that when flex layout is run with that container size,
	each [=flex item=] ends up at least as large as
	its [[#intrinsic-item-contributions|max-content contribution]],
	to the extent allowed by the items’ flexibility.

	The <strong>[=min-content=] [=main size=]  of a <a>flex container</a></strong>
	is, theoretically, the smallest size the [=flex container=] can take
	such that no items overflow it,
	and no item's contents overflow the item--
	setting aside the cases in which the boxes layouts are <em>defined</em> to overflow
	(for example with negative margins or percentage sizes that add up to more than 100%).

	<wpt>
		flex-container-max-content-001.html
		flex-container-min-content-001.html
	</wpt>

	For the min-content size of a multi-line flex container,
	see [[#intrinsic-main-sizes-multiline]].
	For max-content sizes and for single-line min-content sizes,
	an implementation is conformant to CSS Flexible Box Layout
	if it conforms to either the Ideal Algorithm or the Web-compatible Algorithm,
	as defined below.

<h5 id='intrinsic-main-sizes-ideal'>
Ideal Algorithm: Max-content Size and Min-content Single-line Size</h5>

	Note: The following algorithm calculates the [=flex container=]’s ideal
	intrinsic [=main sizes=].
	However, because it was not implemented correctly initially,
	and existing content became dependent on the (unfortunately consistent) incorrect implemented behavior,
	<a href="https://github.com/w3c/csswg-drafts/issues/8884">it is not Web-compatible</a>.
	Implementers and the CSS Working Group are investigating to what extent
	Web browser implementations can safely approach this behavior,
	and further experimentation is welcome.

	Considering only non-[=collapsed=] [=flex items=];

	<ol>
		<li>
			For each <a>flex item</a>,
			subtract its outer <a>flex base size</a> from its [[#intrinsic-item-contributions|max-content contribution]] size.
			If that result is positive,
			divide it by the item's <a>flex grow factor</a>
			if the <a>flex grow factor</a> is &ge; 1,
			or multiply it by the <a>flex grow factor</a>
			if the <a>flex grow factor</a> is < 1;
			if the result is negative,
			divide it by the item's <a>scaled flex shrink factor</a>
			(if dividing by zero, treat the result as negative infinity).
			This is the item's <var>desired flex fraction</var>.

		<li>
			Place all <a>flex items</a> into lines of infinite length.
			Within each line,
			find the greatest (most positive)
			<var>desired flex fraction</var>
			among all the <a>flex items</a>.
			This is the line’s <var>chosen flex fraction</var>.

		<li>
			If the <var>chosen flex fraction</var> is positive,
			and the sum of the line’s <a>flex grow factors</a>
			is less than 1,
			divide the <var>chosen flex fraction</var> by that sum.

			If the <var>chosen flex fraction</var> is negative,
			and the sum of the line’s <a>flex shrink factors</a>
			is less than 1,
			multiply the <var>chosen flex fraction</var> by that sum.

		<li>
			Add each item’s <a>flex base size</a>
			to the product of its <a>flex grow factor</a>
			(<a>scaled flex shrink factor</a>, if shrinking)
			and the <var>chosen flex fraction</var>,
			then clamp that result by the <a>max main size</a>
			floored by the <a>min main size</a>.

		<li>
			The <a>flex container</a>’s <a>max-content size</a> is
			the largest sum (among all the lines)
			of the afore-calculated sizes of all items within a single line.
	</ol>

	The <strong><a>min-content</a> <a>main size</a></strong> of a <em><a>single-line</a></em> flex container
	is calculated identically to the <a>max-content</a> <a>main size</a>,
	except that the <a>flex items</a>’ [[#intrinsic-item-contributions|min-content contributions]] are used
	instead of their [[#intrinsic-item-contributions|max-content contributions]].

	<details class=note>
		<summary>Implications of this algorithm when the sum of flex is less than 1</summary>

		The above algorithm is designed to give the correct behavior for two cases in particular,
		and make the <a>flex container’s</a> size continuous as you transition between the two:

		1. If all items are inflexible,
			the <a>flex container</a> is sized to the sum of their <a>flex base size</a>.
			(An inflexible <a>flex base size</a> basically substitutes for a 'width'/'height',
			which, when specified, is what a <a>max-content contribution</a> is based on in Block Layout.)

		2. When all items are flexible with <a>flex factors</a> ≥ 1,
			the <a>flex container</a> is sized to the sum of the <a>max-content contributions</a> of its items
			(or perhaps a slightly larger size,
			so that every flex item is <em>at least</em> the size of its <a>max-content contribution</a>,
			but also has the correct ratio of its size to the size of the other items,
			as determined by its flexibility).

		For example, if a <a>flex container</a> has a single <a>flex item</a>
		with ''flex-basis: 100px;'' but a max-content size of ''200px'',
		then when the item is ''flex-grow: 0'', the <a>flex container</a> (and <a>flex item</a>) is ''100px'' wide,
		but when the item is ''flex-grow: 1'' or higher, the <a>flex container</a> (and flex item) is ''200px'' wide.

		There are several possible ways to make the overall behavior continuous between these two cases,
		but all of them have drawbacks.
		We chose one we feel has the least bad implications;
		unfortunately, it "double-applies" the flexibility in cases with [=flex factors=] that are < 1.
		In the above example, if the item has ''flex-grow: .5'',
		then the <a>flex container</a> ends up ''150px'' wide,
		but the item then sizes normally into that available space,
		ending up ''125px'' wide.

		<details class=note>
			<summary>Even more involved notes on the specific behavior chosen</summary>

			Principles:

			1. Don't explode any sizes, whether growing or shrinking, as inputs approach zero.
			2. When flex factors are all >=1, return the minimum size necessary for every item to be >= max-content size.
			3. Items with a zero flex shouldn't affect the sizes at all.
			4. Keep it continuous over variance of flex factors and item sizes.
			5. Keep sizing variance as linear as possible with respect to linear changes to any input variable (size, flex factor).
			6. When the sum of flex factors is >=1, return the minimum size necessary for every item to be >= max-content size.

			To get these all to work together,
			we have to apply some correction when either flex factors
			or the sum of flex factors on a line
			is < 1.

			For shrink our behavior is somewhat easier;
			since the explosive case of 0 shrink
			results in a negative infinity desired fraction
			which we'll never choose (since we always take the largest),
			we can just apply the correction at the line level,
			giving us double-application only when the sum is < 1.

			For positives it's more complicated.
			0 grow naively explodes into *positive* infinity,
			which we'd choose,
			so we need to apply the correction at the individual item level.
			We do that by multiplying the space by the factor when factor is <1.
			Leaving it at that would result in a double-application for items < 1
			but sum >= 1,
			but a *triple*-application when the sum is < 1.
			To avoid *that* ridiculousness,
			we apply a *reverse* correction when the sum is 1,
			dividing by the sum instead.
			This leaves us with a double correction in all cases for items with factors < 1.

			We can't eliminate the double-applications entirely
			without giving up other, more important principles
			(in particular, principle 3 --
			try to come up with rules that don't double-apply
			when you have two items with ''flex-grow: .5'',
			but also don't give a ''flex-grow: 0'' item any power
			over a ''flex-grow: 1'' sibling;
			you can't, as far as we can tell.)
		</details>
	</details>

<h5 id="intrinsic-main-sizes-compat">
Web-compatible Intrinsic Sizing Algorithm: Max-content Size and Min-content Single-line Size</h5>

	Note: The following algorithm has been demonstrated to be Web-compatible.
	It may be altered in the future to bring it closer to the ideal algorithm above,
	if possible.

	* For the [=max-content size=] of a [=flex container=],
		take the sum of the [[#intrinsic-item-contributions|max-content contributions]]
		of all the non-[=collapsed=] <a>flex items</a> in the <a>flex container</a>.
	* For the [=min-content size=] of a <em><a>single-line</a></em> container,
		take the sum of the [[#intrinsic-item-contributions|min-content contributions]]
		of all the non-[=collapsed=] <a>flex items</a> in the <a>flex container</a>.


<h5 id="intrinsic-main-sizes-multiline">
Multi-line Min-content Algorithm</h5>

	For a <em><a>multi-line</a></em> container,
	the [=min-content=] [=main size=] is simply the largest [[#intrinsic-item-contributions|min-content contribution]]
	of all the non-[=collapsed=] <a>flex items</a> in the <a>flex container</a>.

<h4 id='intrinsic-cross-sizes'>
Flex Container Intrinsic Cross Sizes</h4>

	The <strong><a>min-content</a>/<a>max-content</a> <a>cross size</a></strong> of a <em><a>single-line</a></em> <a>flex container</a>
	is the largest <a>min-content contribution</a>/<a>max-content contribution</a> (respectively)
	of its <a>flex items</a>.

	For a <em><a>multi-line</a></em> <a>flex container</a>,
	the behavior depends on whether it's a row or column flexbox:

	: ''flex-direction/row''  [=multi-line=] [=flex container=] [=cross size=]
	:: The <a>min-content</a>/<a>max-content</a> <a>cross size</a>
		is the sum of the flex line cross sizes
		resulting from sizing the flex container
		under a <a>cross-axis</a> <a>min-content constraint</a>/<a>max-content constraint</a> (respectively).

	: ''flex-direction/column'' [=multi-line=] [=flex container=] [=cross size=]
	:: The [=min-content=] [=cross size=]
		is the largest [=min-content contribution=] among all of its [=flex items=].

		Note: This heuristic effectively assumes a single flex line,
		in order to guarantee that the [=min-content size=]
		is smaller than the [=max-content size=].
		If the flex container has a height constraint,
		this will result in overflow,
		but if the [=flex container=] is also a [=block-axis scroll container|main-axis scroll container=],
		it will at least be large enough to fit
		any given column entirely within its [=scrollport=].

		The [=max-content=] [=cross size=] is the sum of the [=flex line=] cross sizes
		resulting from sizing the [=flex container=]
		under a <a>cross-axis</a> <a>max-content constraint</a>,
		using the largest <a lt="max-content contribution">max-content</a> cross-size contribution among the <a>flex items</a>
		as the <a>available space</a> in the <a>cross axis</a>
		for each of the <a>flex items</a> during layout.

		Note: This heuristic gives a reasonable approximation
		of the size that the <a>flex container</a> should be,
		with each [=flex item=] laid out at its [=max-content contribution=] or larger,
		and each <a>flex line</a> no larger than its largest <a>flex item</a>.
		It's not a <em>perfect</em> fit in some cases,
		but doing it completely correct is insanely expensive,
		and this works reasonably well.

	<wpt>
		flexbox_width-change-and-relayout-children.html
		table-as-flex-item-max-content.html
		table-as-item-flex-cross-size.html
	</wpt>


<h4 id='intrinsic-item-contributions'>
Flex Item Intrinsic Size Contributions</h4>

	The <strong>main-size <a>min-content contribution</a> of a <a>flex item</a></strong>
	is the larger of its <em>outer</em> <a>min-content size</a>
	and outer <a>preferred size</a>
	if that is not an [=automatic size=].

	The <strong>main-size <a>max-content contribution</a> of a <a>flex item</a></strong>
	is the larger of its <em>outer</em> <a>max-content size</a>
	and outer <a>preferred size</a>
	if that is not an [=automatic size=].

	For this purpose,
	each contribution
	is capped by the item’s [=flex base size=] if the item is not growable,
	floored by the item’s [=flex base size=] if the item is not shrinkable,
	and then further clamped by the item's <a lt="min main size">min</a>/<a>max main size</a>.

<!--
████████ ████████     ███     ██████   ██     ██ ████████ ██    ██ ████████ ████ ██    ██  ██████
██       ██     ██   ██ ██   ██    ██  ███   ███ ██       ███   ██    ██     ██  ███   ██ ██    ██
██       ██     ██  ██   ██  ██        ████ ████ ██       ████  ██    ██     ██  ████  ██ ██
██████   ████████  ██     ██ ██   ████ ██ ███ ██ ██████   ██ ██ ██    ██     ██  ██ ██ ██ ██   ████
██       ██   ██   █████████ ██    ██  ██     ██ ██       ██  ████    ██     ██  ██  ████ ██    ██
██       ██    ██  ██     ██ ██    ██  ██     ██ ██       ██   ███    ██     ██  ██   ███ ██    ██
██       ██     ██ ██     ██  ██████   ██     ██ ████████ ██    ██    ██    ████ ██    ██  ██████
-->

<h2 id="pagination">
Fragmenting Flex Layout</h2>

	<p>
		Flex containers can break across pages
		between items,
		between lines of items (in <a>multi-line</a> mode),
		and inside items.
		The <a property lt="break-before">break-*</a> properties apply to flex containers as normal for block-level or inline-level boxes.
		This section defines how they apply to flex items
		and the contents of flex items.
		See the <a href="http://www.w3.org/TR/css-break/">CSS Fragmentation Module</a>
		for more context [[!CSS3-BREAK]].

	<p>
		The following breaking rules refer to the <a>fragmentation container</a> as the “page”.
		The same rules apply in any other <a>fragmentation context</a>.
		(Substitute “page” with the appropriate <a>fragmentation container</a> type as needed.)
		For readability, in this section the terms "row" and "column" refer to the relative orientation
		of the <a>flex container</a> with respect to the block flow direction of the <a>fragmentation context</a>,
		rather than to that of the <a>flex container</a> itself.

	<p>
		The exact layout of a fragmented flex container
		is not defined in this level of Flexible Box Layout.
		However, breaks inside a flex container are subject to the following rules
		(interpreted using <a>order-modified document order</a>):

	<ul>
		<li>
			In a row flex container,
			the 'break-before' and 'break-after' values on flex items
			are propagated to the flex line.
			The 'break-before' values on the first line
			and the 'break-after' values on the last line
			are propagated to the flex container.

			Note: Break propagation
			(like 'text-decoration' propagation)
			does not affect <a>computed values</a>.

		<li>
			In a column flex container,
			the 'break-before' values on the first item
			and the 'break-after' values on the last item
			are propagated to the flex container.
			Forced breaks on other items are applied to the item itself.

		<li>
			A forced break inside a flex item effectively increases the size of its contents;
			it does not trigger a forced break inside sibling items.

		<li>
			In a row flex container,
			<a href="https://www.w3.org/TR/css3-break/#btw-blocks">Class A break opportunities</a> occur between sibling flex lines,
			and <a href="https://www.w3.org/TR/css3-break/#end-block">Class C break opportunities</a> occur between the first/last flex line and the flex container's content edges.
			In a column flex container,
			<a href="https://www.w3.org/TR/css3-break/#btw-blocks">Class A break opportunities</a> occur between sibling flex items,
			and <a href="https://www.w3.org/TR/css3-break/#end-block">Class C break opportunities</a> occur between the first/last flex items on a line and the flex container's content edges.
			[[!CSS3-BREAK]]

		<li>
			When a flex container is continued after a break,
			the space available to its <a>flex items</a>
			(in the block flow direction of the fragmentation context)
			is reduced by the space consumed by flex container fragments on previous pages.
			The space consumed by a flex container fragment is
			the size of its content box on that page.
			If as a result of this adjustment the available space becomes negative,
			it is set to zero.

		<li>
			If the first fragment of the flex container is not at the top of the page,
			and none of its flex items fit in the remaining space on the page,
			the entire fragment is moved to the next page.

<li>
			When breaking a <a>multi-line</a> column flex container,
			the UA may organize each fragment into its own “stack” of flex lines--
			just like each fragment of a multi-column container
			has its own row of column boxes--
			in order to ensure that content presented on earlier pages
			corresponds to content earlier in the box order.

		<li>
			Aside from the rearrangement of items imposed by the previous point,
			UAs should attempt to minimize distortion of the flex container
			with respect to unfragmented flow.
	</ul>

	<wpt>
		interactive/flexbox_interactive_break-after-column-item.html
		interactive/flexbox_interactive_break-after-column-lastitem.html
		interactive/flexbox_interactive_break-after-container.html
		interactive/flexbox_interactive_break-after-item.html
		interactive/flexbox_interactive_break-after-line.html
		interactive/flexbox_interactive_break-after-line-order.html
		interactive/flexbox_interactive_break-after-multiline.html
		interactive/flexbox_interactive_break-before-column-firstitem.html
		interactive/flexbox_interactive_break-before-column-item.html
		interactive/flexbox_interactive_break-before-container.html
		interactive/flexbox_interactive_break-before-item.html
		interactive/flexbox_interactive_break-before-multiline.html
		interactive/flexbox_interactive_break-natural.html
	</wpt>


<h3 id='pagination-algo'>
Sample Flex Fragmentation Algorithm</h3>

	<p>
		This informative section presents a possible fragmentation algorithm for flex containers.
		Implementors are encouraged to improve on this algorithm and <a href='#sotd'>provide feedback to the CSS Working Group</a>.

<div class='example'>

	<p class='note'>
		This algorithm assumes that pagination always proceeds only in the forward direction;
		therefore, in the algorithms below, alignment is mostly ignored prior to pagination.
		Advanced layout engines may be able to honor alignment across fragments.

	<dl>
		<dt><a>single-line</a> column flex container
		<dd>
			<ol>
				<li>
					Run the flex layout algorithm (without regards to pagination)
					through <a href="#cross-sizing">Cross Sizing Determination</a>.

				<li>
					Lay out as many consecutive flex items or item fragments as possible
					(but at least one or a fragment thereof),
					starting from the first,
					until there is no more room on the page
					or a forced break is encountered.

				<li>
					If the previous step ran out of room
					and the free space is positive,
					the UA may reduce the distributed free space on this page
					(down to, but not past, zero)
					in order to make room for the next unbreakable flex item or fragment.
					Otherwise,
					the item or fragment that does not fit is pushed to the next page.
					The UA should pull up if more than 50% of the fragment would have fit in the remaining space
					and should push otherwise.

				<li>
					If there are any flex items or fragments not laid out by the previous steps,
					rerun the flex layout algorithm
					from <a href="#line-sizing">Line Length Determination</a>
					through <a href="#cross-sizing">Cross Sizing Determination</a>
					with the next page's size
					and <em>all</em> the contents (including those already laid out),
					and return to the previous step,
					but starting from the first item or fragment not already laid out.

				<li>
					For each fragment of the flex container,
					continue the flex layout algorithm
					from <a href="#main-alignment">Main-Axis Alignment</a>
					to its finish.
			</ol>

			<p class="note">
				It is the intent of this algorithm that column-direction <a>single-line</a> flex containers
				paginate very similarly to block flow.
				As a test of the intent,
				a flex container with ''justify-content:start''
				and no flexible items
				should paginate identically to
				a block with <a>in-flow</a> children with same content,
				same used size and same used margins.

		<dt><a>multi-line</a> column flex container
		<dd>
			<ol>
				<li>
					Run the flex layout algorithm
					<em>with</em> regards to pagination
					(limiting the flex container's maximum line length to the space left on the page)
					through <a href="#cross-sizing">Cross Sizing Determination</a>.

				<li>
					Lay out as many flex lines as possible
					(but at least one)
					until there is no more room in the flex container
					in the cross dimension
					or a forced break is encountered:

					<ol>
						<li>
							Lay out as many consecutive flex items as possible
							(but at least one),
							starting from the first,
							until there is no more room on the page
							or a forced break is encountered.
							Forced breaks <em>within</em> flex items are ignored.

						<li>
							If this is the first flex container fragment,
							this line contains only a single flex item
							that is larger than the space left on the page,
							and the flex container is not at the top of the page already,
							move the flex container to the next page
							and restart flex container layout entirely.

						<li>
							If there are any flex items not laid out by the first step,
							rerun the flex layout algorithm
							from <a href="#main-sizing">Main Sizing Determination</a>
							through <a href="#cross-sizing">Cross Sizing Determination</a>
							using only the items not laid out on a previous line,
							and return to the previous step,
							starting from the first item not already laid out.
					</ol>

				<li>
					If there are any flex items not laid out by the previous step,
					rerun the flex layout algorithm
					from <a href="#line-sizing">Line Sizing Determination</a>
					through <a href="#cross-sizing">Cross Sizing Determination</a>
					with the next page's size
					and only the items not already laid out,
					and return to the previous step,
					but starting from the first item not already laid out.

				<li>
					For each fragment of the flex container,
					continue the flex layout algorithm
					from <a href="#main-alignment">Main-Axis Alignment</a>
					to its finish.
			</ol>

			<p class='note'>
				A shortcoming of this sample algorithm is that
				if a flex item does not entirely fit on a single page,
				it will <em>not</em> be paginated in <a>multi-line</a> column flex containers.

		<dt><a>single-line</a> row flex container
		<dd>
			<ol>
				<li>
					Run the entire flex layout algorithm (without regards to pagination),
					except treat any 'align-self' other than ''align-self/flex-start'' or ''baseline''
					as ''align-self/flex-start''.

				<li>
					If an unbreakable item doesn't fit within the space left on the page,
					and the flex container is not at the top of the page,
					move the flex container to the next page
					and restart flex container layout entirely.

				<li>
					For each item,
					lay out as much of its contents as will fit in the space left on the page,
					and fragment the remaining content onto the next page,
					rerunning the flex layout algorithm
					from <a href="#line-sizing">Line Length Determination</a>
					through <a href="#main-alignment">Main-Axis Alignment</a>
					into the new page size
					using <em>all</em> the contents (including items completed on previous pages).

					<p class='note'>
						Any flex items that fit entirely into previous fragments
						still take up space in the main axis in later fragments.

				<li>
					For each fragment of the flex container,
					rerun the flex layout algorithm
					from <a href="#cross-alignment">Cross-Axis Alignment</a>
					to its finish.
					For all fragments besides the first,
					treat 'align-self' and 'align-content' as being ''align-self/flex-start'' for all item fragments and lines.

				<li>
					If any item,
					when aligned according to its original 'align-self' value
					into the combined <a>cross size</a> of all the flex container fragments,
					would fit entirely within a single flex container fragment,
					it may be shifted into that fragment
					and aligned appropriately.
			</ol>

		<dt><a>multi-line</a> row flex container
		<dd>
			<ol>
				<li>
					Run the flex layout algorithm (without regards to pagination),
					through <a href="#cross-sizing">Cross Sizing Determination</a>.

				<li>
					Lay out as many flex lines as possible
					(but at least one),
					starting from the first,
					until there is no more room on the page
					or a forced break is encountered.

					<p>
						If a line doesn't fit on the page,
						and the line is not at the top of the page,
						move the line to the next page
						and restart the flex layout algorithm entirely,
						using only the items in and following this line.

					<p>
						If a flex item itself causes a forced break,
						rerun the flex layout algorithm
						from <a href="#main-sizing">Main Sizing Determination</a>
						through <a href="#main-alignment">Main-Axis Alignment</a>,
						using only the items on this and following lines,
						but with the item causing the break automatically starting a new line
						in the <a href="#algo-line-break">line breaking step</a>,
						then continue with this step.
						Forced breaks <em>within</em> flex items are ignored.

				<li>
					If there are any flex items not laid out by the previous step,
					rerun the flex layout algorithm
					from <a href="#line-sizing">Line Length Determination</a>
					through <a href="#main-alignment">Main-Axis Alignment</a>
					with the next page's size
					and only the items not already laid out.
					Return to the previous step,
					but starting from the first line not already laid out.

				<li>
					For each fragment of the flex container,
					continue the flex layout algorithm
					from <a href="#cross-alignment">Cross Axis Alignment</a>
					to its finish.
			</ol>
	</dl>
</div>

<h2 class="no-num" id="axis-mapping">
Appendix A: Axis Mappings</h2>

	<em>This appendix is non-normative.</em>

	<table class="data" id="axis-mapping-table-en">
		<caption>Axis Mappings for ''ltr'' + ''horizontal-tb'' <a>Writing Mode</a> (e.g. English)</caption>
		<colgroup span=1></colgroup>
		<colgroup span=3></colgroup>
		<colgroup span=3></colgroup>
		<thead>
			<tr>
				<th>'flex-flow'
				<th><a>main axis</a>
				<th><a>start</a>
				<th><a>end</a>
				<th><a>cross axis</a>
				<th><a>start</a>
				<th><a>end</a>
		<tbody>
			<tr>
				<th>''row'' + ''nowrap''/''wrap''
				<td rowspan=4>horizontal
				<td>left
				<td>right
				<td rowspan=4>vertical
				<td rowspan=2>top
				<td rowspan=2>bottom
			<tr>
				<th>''row-reverse'' + ''nowrap''/''wrap''
				<td>right
				<td>left
			<tr>
				<th>''row'' + ''wrap-reverse''
				<td>left
				<td>right
				<td rowspan=2>bottom
				<td rowspan=2>top
			<tr>
				<th>''row-reverse'' + ''wrap-reverse''
				<td>right
				<td>left
			<tr>
				<th>''column'' + ''nowrap''/''wrap''
				<td rowspan=4>vertical
				<td>top
				<td>bottom
				<td rowspan=4>horizontal
				<td rowspan=2>left
				<td rowspan=2>right
			<tr>
				<th>''column-reverse'' + ''nowrap''/''wrap''
				<td>bottom
				<td>top
			<tr>
				<th>''column'' + ''wrap-reverse''
				<td>top
				<td>bottom
				<td rowspan=2>right
				<td rowspan=2>left
			<tr>
				<th>''column-reverse'' + ''wrap-reverse''
				<td>bottom
				<td>top
	</table>

	<table class="data" id="axis-mapping-table-fa">
		<caption>Axis Mappings for ''rtl'' + ''horizontal-tb'' <a>Writing Mode</a> (e.g. Farsi)</caption>
		<colgroup span=1></colgroup>
		<colgroup span=3></colgroup>
		<colgroup span=3></colgroup>
		<thead>
			<tr>
				<th>'flex-flow'
				<th><a>main axis</a>
				<th><a>main-start</a>
				<th><a>main-end</a>
				<th><a>cross axis</a>
				<th><a>cross-start</a>
				<th><a>cross-end</a>
		<tbody>
			<tr>
				<th>''row'' + ''nowrap''/''wrap''
				<td rowspan=4>horizontal
				<td>right
				<td>left
				<td rowspan=4>vertical
				<td rowspan=2>top
				<td rowspan=2>bottom
			<tr>
				<th>''row-reverse'' + ''nowrap''/''wrap''
				<td>left
				<td>right
			<tr>
				<th>''row'' + ''wrap-reverse''
				<td>right
				<td>left
				<td rowspan=2>bottom
				<td rowspan=2>top
			<tr>
				<th>''row-reverse'' + ''wrap-reverse''
				<td>left
				<td>right
			<tr>
				<th>''column'' + ''nowrap''/''wrap''
				<td rowspan=4>vertical
				<td>top
				<td>bottom
				<td rowspan=4>horizontal
				<td rowspan=2>right
				<td rowspan=2>left
			<tr>
				<th>''column-reverse'' + ''nowrap''/''wrap''
				<td>bottom
				<td>top
			<tr>
				<th>''column'' + ''wrap-reverse''
				<td>top
				<td>bottom
				<td rowspan=2>left
				<td rowspan=2>right
			<tr>
				<th>''column-reverse'' + ''wrap-reverse''
				<td>bottom
				<td>top
	</table>

	<table class="data" id="axis-mapping-table-ja">
		<caption>Axis Mappings for ''ltr'' + ''vertical-rl'' <a>Writing Mode</a> (e.g. Japanese)</caption>
		<colgroup span=1></colgroup>
		<colgroup span=3></colgroup>
		<colgroup span=3></colgroup>
		<thead>
			<tr>
				<th>'flex-flow'
				<th><a>main axis</a>
				<th><a lt=main-start><abbr title="cross-start">start</abbr></a>
				<th><a lt=main-end><abbr title="cross-end">end</abbr></a>
				<th><a>cross axis</a>
				<th><a lt=cross-start><abbr title="cross-start">start</abbr></a>
				<th><a lt=cross-end><abbr title="cross-end">end</abbr></a>
		<tbody>
			<tr>
				<th>''row'' + ''nowrap''/''wrap''
				<td rowspan=4>vertical
				<td>top
				<td>bottom
				<td rowspan=4>horizontal
				<td rowspan=2>right
				<td rowspan=2>left
			<tr>
				<th>''row-reverse'' + ''nowrap''/''wrap''
				<td>bottom
				<td>top
			<tr>
				<th>''row'' + ''wrap-reverse''
				<td>top
				<td>bottom
				<td rowspan=2>left
				<td rowspan=2>right
			<tr>
				<th>''row-reverse'' + ''wrap-reverse''
				<td>bottom
				<td>top
			<tr>
				<th>''column'' + ''nowrap''/''wrap''
				<td rowspan=4>vertical
				<td>right
				<td>left
				<td rowspan=4>horizontal
				<td rowspan=2>top
				<td rowspan=2>bottom
			<tr>
				<th>''column-reverse'' + ''nowrap''/''wrap''
				<td>left
				<td>right
			<tr>
				<th>''column'' + ''wrap-reverse''
				<td>right
				<td>left
				<td rowspan=2>bottom
				<td rowspan=2>top
			<tr>
				<th>''column-reverse'' + ''wrap-reverse''
				<td>left
				<td>right
	</table>

<h2 class="no-num" id="webkit-aliases">
Appendix B: <code>-webkit-</code> Legacy Properties</h2>

	<em>This appendix is normative.</em>

	Advisement: These aliases are <em>deprecated</em>
	and authors <em>should not</em> use them
	unless their content needs to support actively-used legacy UAs.

	For compatibility with general Web content,
	UAs that are Web browsers must and other UAs may
	implement the following [=legacy name aliases=]:

	<table class=data>
	<thead>
		<tr><th>Alias	<th>Standard
	<tbody>
		<tr><td>-webkit-align-content<td>align-content
		<tr><td>-webkit-align-items<td>align-items
		<tr><td>-webkit-align-self<td>align-self
		<tr><td>-webkit-flex<td>flex
		<tr><td>-webkit-flex-basis<td>flex-basis
		<tr><td>-webkit-flex-direction<td>flex-direction
		<tr><td>-webkit-flex-flow<td>flex-flow
		<tr><td>-webkit-flex-grow<td>flex-grow
		<tr><td>-webkit-flex-shrink<td>flex-shrink
		<tr><td>-webkit-flex-wrap<td>flex-wrap
		<tr><td>-webkit-justify-content<td>justify-content
		<tr><td>-webkit-order<td>order
	</table>

	<wpt>
		flexbox_width-wrapping-column.html
		parsing/webkit-aliases.html
		webkit-box-vertical-writing-mode.html
	</wpt>

<h2 class="no-num" id="acknowledgments">Acknowledgments</h2>

	<p>Thanks for feedback and contributions to

Erik Anderson,
Christian Biesinger,
Tony Chang,
Phil Cupp,
Arron Eicholz,
James Elmore,
Andrew Fedoniouk,
Brian Heuston,
Shinichiro Hamaji,
Daniel Holbert,
Ben Horst,
John Jansen,
Brad Kemper,
Kang-hao Lu,
Markus Mielke,
Peter Moulder,
Robert O'Callahan,
Christoph Päper,
Ning Rogers,
Peter Salas,
Elliott Sprehn,
Morten Stenshorne,
Christian Stockwell,
Ojan Vafai,
Eugene Veselov,
Greg Whitworth,
Boris Zbarsky.

<!--
 ██████  ██     ██    ███    ██    ██  ██████   ████████  ██████
██    ██ ██     ██   ██ ██   ███   ██ ██    ██  ██       ██    ██
██       ██     ██  ██   ██  ████  ██ ██        ██       ██
██       █████████ ██     ██ ██ ██ ██ ██   ████ ██████    ██████
██       ██     ██ █████████ ██  ████ ██    ██  ██             ██
██    ██ ██     ██ ██     ██ ██   ███ ██    ██  ██       ██    ██
 ██████  ██     ██ ██     ██ ██    ██  ██████   ████████  ██████
-->

<h2 class="no-num" id="changes">Changes</h2>

	This section documents the changes since previous publications.

<h3 id="changes-20251014">
Changes since the <a href="https://www.w3.org/TR/2025/CRD-css-flexbox-1-20251014/">14 October 2025 CRD</a>
</h3>

	<ul>
		<li id="change-2025-scroll-axis">
			When appropriate, mention [=scrollable axises=].
			(<a href="https://github.com/w3c/csswg-drafts/issues/12289">Issue 12289</a>)

		<li id="change-2025-web-compat-intrinsic">
			Defined the web-compatible intrinsic sizing algo in [[#intrinsic-main-sizes-compat]].
			(<a href="https://github.com/w3c/csswg-drafts/issues/8884#issuecomment-1636311498">Issue 8884</a>)

		<li id="change-2025-cross-size-recalc">
			Clarified that the used cross size of an item is recalculated
			with the line's cross size as its available space.
			(<a href="https://github.com/w3c/csswg-drafts/issues/11784">Issue 11784</a>)
	</ul>

<h3 id="changes-20181119">
Changes since the <a href="https://www.w3.org/TR/2018/CR-css-flexbox-1-20181119/">19 November 2018 CR</a></h3>

	A <a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2018">Disposition of Comments</a>
	is available.
	Significant changes include:

	<ul>
		<li id="change-2018-intrinsic-main-size-compat">
			Identify parts of [[#intrinsic-main-sizes]] as ideal but not Web-compatible,
			and mark a refined Web-compatible algorithm as an ongoing investigation.
			(<a href="https://github.com/w3c/csswg-drafts/issues/8884">Issue 8884</a>)

		<li id="change-2018-intrinsic-main-size-errors">
			Fix errors in the flexing rules in [[#intrinsic-main-sizes]]
			to closer match the actual layout algorithm
			and avoid dividing by zero or exploding sizes as inputs approach zero.
			(<a href="https://github.com/w3c/csswg-drafts/issues/7189#issuecomment-1172771501">Issue 7189</a>)

		<li id="change-2018-min-content-column-size-compat">
			Reform the [[#intrinsic-cross-sizes|cross-size intrinsic sizing rules]]
			for column wrap flex containers to yield better results.
			(Issue <a href="https://github.com/w3c/csswg-drafts/issues/6777">6777</a>)

		<li id="change-2018-static-pos-align-content">
			Use the [=content edges=] of the [=flex container=]
			for determining the [=static-position rectangle=] of flex container children,
			rather than doing extra layout work.
			This will result in ignoring 'align-content' on the flex container,
			but allow 'align-self' on the box itself to still take effect.
			(<a href="https://github.com/w3c/csswg-drafts/issues/5843">Issue 5843</a>,
			<a href="https://github.com/w3c/csswg-drafts/issues/7596">7596</a>)

		<li id="change-2018-correctly-ignore-auto">
			Correctly ignore ''width/auto'' [=preferred sizes=]
			in both min <em>and</em> max size contribution calculations.
			(It was accidentally omitted from the max,
			though it shows up correctly
			in the <a href="#change-2017-flex-min-contribution">changelog</a>...)
			(<a href="https://github.com/w3c/csswg-drafts/issues/6455">Issue 6455</a>)

		<li id="change-2018-move-order">
			Moved the 'order' property definition to [[CSS-DISPLAY-3]].
			See [[#order-property]] for remaining explanation.
			(<a href="https://github.com/w3c/csswg-drafts/issues/5865">Issue 5865</a>)

		<li id="change-2018-definite-basis-definite">
			Made [=main size=] always [=definite=] for [=flex items=] with a [=definite=] [=flex basis=],
			to match implementations.
			(<a href="https://github.com/w3c/csswg-drafts/issues/4311">Issue 4311</a>)
			<blockquote>
				<ol>
					<li>If the [=flex container=] has a [=definite=] [=main size=],
					<ins>then the post-flexing [=main sizes=]
					of its [=flex items=]
					are treated as [=definite=]</ins>
					<del>a <a>flex item</a>’s post-flexing <a>main size</a>
					is treated as <a>definite</a>,
					even though it can rely on the <a>indefinite</a> sizes
					of any flex items in the same line</del>.

					<li><ins>If a [=flex item’s=] [=flex basis=] is [=definite=],
					then its post-flexing [=main size=] is also [=definite=].</ins>
				</ol>
			</blockquote>
			<blockquote>
				<p class="note"><del>Note: The main size of a <a>fully inflexible</a> item
				with a <a spec=css-sizing-3>definite</a> <a>flex basis</a>
				is, by definition, <a spec=css-sizing-3>definite</a>.</del>

				<p class="note"><ins>Note: This means that within [=flex layout=],
				“definite” sizes can require performing layout.
				This was done to allow percentages inside of [=flex items=]
				to resolve where authors expected them to resolve.</ins>
			</blockquote>

		<li id="change-2018-flex-column-wrap-fragmentation">
			Made the re-arrangement of [=flex items=] into independent
			stacks of flex lines on each page optional,
			and identified shortcomings in the sample algorithm.
			(<a href="https://github.com/w3c/csswg-drafts/issues/6855">6855</a>)

		<li id="change-2018-bracket-range-notation">
			Updated value syntax in property definition tables
			to use newer <a>CSS bracketed range notation</a>
			reflecting the prose restrictions on negative values.
			(Editorial.)

		<li id="change-2018-preferred-aspect-ratio">
			Updated aspect ratio terminology to use the term [=preferred aspect ratio=],
			and clarify any uses that are specific to [=replaced elements=],
			in order to accommodate forthcoming 'aspect-ratio' property.

		<li id="change-2018-auto-min-aspect-ratio">
			Define interaction of 'aspect-ratio' and the [=automatic minimum size=]
			by applying its effect to the [=transferred size suggestion=]
			and excluding it from the definiteness of the [=specified size suggestion=].
			(Issues <a href="https://github.com/w3c/csswg-drafts/issues/6069">6069</a>
			and <a href="https://github.com/w3c/csswg-drafts/issues/6794">6794</a>,
			<a href="https://github.com/w3c/csswg-drafts/pull/11690">changeset A</a>
			and <a href="https://github.com/w3c/csswg-drafts/commit/ca4dc9e0a3815be0306645dab03f8ca52434baf9">changeset B</a>)

		<li id="change-2018-auto-min-size-overflow">
			Pin [=automatic minimum size=] conditional on [=computed value=] of 'overflow'
			rather than on being a [=scroll container=]
			to avoid cases such as [=replaced elements=]
			whose computed [=scrollable overflow values=] resolve to
			[=non-scrollable overflow values|non-scrollable=] [=used values=].
			(<a href="https://github.com/w3c/csswg-drafts/issues/7714">7714</a>)

		<li id="change-2018-indefinite-min-intrinsic">
			Clarify that the rule exempting [=content-based minimum sizes=]
			from making an item’s size to be indefinite
			is limited to ''min-width/auto'', and does not affect other intrinsic sizing keywords.
			(<a href="https://github.com/w3c/csswg-drafts/issues/6457">Issue 6457</a>)

		<li id="change-2018-collapsed-intrinsic-container">
			Explicitly excluded [=collapsed flex items=]
			from the [[#intrinsic-main-sizes|intrinsic main size calculations]].
			(<a href="https://github.com/w3c/csswg-drafts/issues/5985">Issue 5985</a>)
			<blockquote>
				<p>The <strong><a>max-content</a> <a>main size</a> of a <a>flex container</a></strong>
				is the smallest size the <a>flex container</a> can take
				while maintaining the [[#intrinsic-item-contributions|max-content contributions]] of its <a>flex items</a>,
				insofar as allowed by the items’ own flexibility.
				<ins>Considering only non-[=collapsed=] [=flex items=]:</ins>
			</blockquote>
			<blockquote>
				However, for a <em><a>multi-line</a></em> container,
				it is simply the largest [[#intrinsic-item-contributions|min-content contribution]]
				of all the <ins>non-[=collapsed=]</ins> <a>flex items</a> in the <a>flex container</a>.
			</blockquote>

		<li id="change-2018-used-cross-size">
			Clarified that the [=flex base size=] calculations
			rely on the <em>used</em> [=cross size=].
			(<a href="https://github.com/w3c/csswg-drafts/issues/3736">Issue 3736</a>)
			<blockquote>
				<p>&hellip; then the flex base size is calculated from
				its <ins>used</ins> inner cross size
				and the flex item’s intrinsic aspect ratio.
			</blockquote>

		<li id="change-2018-flexible-length-text">
			Slightly restructured the prose in [[#resolve-flexible-lengths]]
			to fix errors.
			(<a href="https://github.com/w3c/csswg-drafts/issues/5179">Issue 5179</a>)

		<li id="change-2018-cross-layout">
			Clarified that “performing layout” means using the block-level layout rules.
			(<a href="https://github.com/w3c/csswg-drafts/issues/5188">Issue 5188</a>)

			<blockquote>
				<p><strong>Determine the hypothetical cross size of each item</strong>
				by performing layout <ins>as if it were an [=in-flow=] [=block-level box=]</ins>
				with the used <a>main size</a> and the <ins>given</ins> available space &hellip;
			</blockquote>

		<li id="change-2018-cross-sizing">
			Rewrote flex-contain cross-sizing step
			to depend on the rules of whatever formatting context it's in,
			rather than assuming block-layout rules.
			(<a href="https://github.com/w3c/csswg-drafts/issues/5190">Issue 5190</a>)

			<blockquote>
				<strong>Determine the flex container's used cross size</strong>
				<ins>using the rules of the [=formatting context=] in which it participates.
				If a content-based [=cross size=] is needed,
				use the sum of the [=flex lines=]' [=cross sizes=].</ins>

				<del>
					<ul>
						<li>
							If the cross size property is a <a>definite</a> size,
							use that,
							clamped by the used min and max [=cross size|cross sizes=]
							of the <a>flex container</a>.

						<li>
							Otherwise,
							use the sum of the flex lines' cross sizes,
							clamped by the used min and max [=cross size|cross sizes=]
							of the <a>flex container</a>.
					</ul>
				</del>
			</blockquote>

		<li id="change-2018-aspect-ratio-box">
			Removed explicit mention of which box to use for calculating aspect-ratio,
			to allow for behavior introduced by the new 'aspect-ratio' property in [[css-sizing-4]].
			(<a href="https://github.com/w3c/csswg-drafts/issues/5246/">Issue 5246</a>)

			<blockquote>
				then the flex base size is calculated from
				its used <del>inner</del> cross size
				and the flex item’s intrinsic aspect ratio.
			</blockquote>

		<li id="change-2018-auto-min-contribution">
			Clarified that the [=content-based minimum size=] of a flex item
			is a type of [=intrinsic size contribution=],
			and thus impacted by associated rules in [[CSS-SIZING-3]].
			(<a href="https://github.com/w3c/csswg-drafts/issues/5665#issuecomment-738391191">Issue 5665</a>)
			<blockquote>
				Note: The [=content-based minimum size=] is a type of [=intrinsic size contribution=],
				and thus the provisions in [[css-sizing-3#intrinsic-contribution]] apply.
			</blockquote>

		<li id="change-2018-safe-fallback">
			Made the fallback alignment (in case of negative free space)
			for the ''space-*'' keywords apply ''overflow-position/safe''.
			(<a href="https://github.com/w3c/csswg-drafts/issues/10154">Issue 10154</a>)

		<li id="change-2018-content-based-editorial">
			Redrafted the definition of [=content-based minimum size=]
			for easier reading. (Editorial)

		<li id="change-2018-webkit-aliases">
			Added [[#webkit-aliases]] to document <code>-webkit-</code> aliases of flex layout properties
			that are necessary for Web-compat.
			(<a href="https://github.com/w3c/csswg-drafts/issues/5634">Issue 5634</a>)

		<li id="change-2018-blockification">
			Rephrased blockification rules in terms of [=computed values=].
			(<a href="https://github.com/w3c/csswg-drafts/issues/4065">Issue 4065</a>)

		<li>
			Various minor editorial fixes and clarifications,
	</ul>

<h3 id="changes-20171016">
Changes since the 16 October 2017 CR</h3>

	A <a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2017">Disposition of Comments</a> is also available.

	<ul>
		<li id="change-2017-margin-padding-percent">
			Removed the option for flex-item block-axis margins and paddings
			to be resolved against the block dimension;
			they must be resolved against the inline dimension, as for blocks.
			(<a href="https://github.com/w3c/csswg-drafts/issues/2085">Issue 2085</a>)

		<li id="change-2017-flex-min-contribution">
			Floored <a>flex item</a>’s <a>min-content contribution</a>
			by their <a>preferred size</a>
			(<a href="https://github.com/w3c/csswg-drafts/issues/2353">Issue 2353</a>)
			and cleaned up associated wording to be more precise.
			<blockquote>
				The main-size <a>min-content contribution</a> of a <a>flex item</a>
				is the larger of its <em>outer</em> <a>min-content size</a>
				<ins>and outer <a>preferred size</a> (its 'width'/'height' as appropriate)
				if that is not ''width/auto''</ins>,
				clamped by its <a>flex base size</a> as a maximum (if it is not growable)
				and/or as a minimum (if it is not shrinkable),
				and then further clamped by its <a lt="min main size property">min</a>/<a>max main size properties</a>.

				The main-size <a>max-content contribution</a> of a <a>flex item</a>
				is the larger of its <em>outer</em> <a>max-content size</a>
				and <ins>outer</ins> <del>specified</del> <ins>preferred</ins> size
				(its 'width'/'height' as appropriate<del>,</del><ins>)</ins>
				if that is <del>definite</del><ins>not ''width/auto''</ins>,
				clamped by its <a>flex base size</a> as a maximum (if it is not growable)
				and/or as a minimum (if it is not shrinkable),
				and then further clamped by its <a lt="min main size property">min</a>/<a>max main size properties</a>.
			</blockquote>

		<li id="change-2017-content-desc">
			Added some (effectively informative) prose and a cross-reference
			to more clearly define ''flex-basis: content''.
			<blockquote>
				<p>
				Indicates <del>automatic sizing</del> <ins>an <a href="#algo-main-item">automatic size</a></ins>
				based on the <a>flex item</a>’s content.
				<ins>(It is typically equivalent to the <a>max-content size</a>,
				but with adjustments to handle aspect ratios,
				intrinsic sizing constraints,
				and orthogonal flows;
				see <a href="#algo-main-item">details</a> in [[#layout-algorithm]].)</ins>
				</p>
			</blockquote>

		<li id="change-2017-min-size-auto">
			Moved the definition of the ''min-width/auto'' keyword for 'min-width' and 'min-height'
			to [[!CSS-SIZING-3]].
			The definition of what an <a>automatic minimum size</a> for flex items is remains here.
			(<a href="https://github.com/w3c/csswg-drafts/issues/1920">Issue 1920</a>,
			<a href="https://github.com/w3c/csswg-drafts/issues/2103">Issue 2103</a>)

		<li id="change-2017-min-size-auto-computation">
			Altered the computation of ''min-width/auto'' in 'min-width' and 'min-height'
			such that it always computes to itself--
			although its <a>resolved value</a> remains zero on CSS2 display types.
			(<a href="https://github.com/w3c/csswg-drafts/issues/2230">Issue 2230</a>,
			<a href="https://github.com/w3c/csswg-drafts/issues/2248">Issue 2248</a>)

		<li id="change-2017-used-min-sizes">
			Clarified that min/max clamping is according to the <a>used value</a>
			of the min/max size properties--
			which in the case of tables with ''table-layout/auto'' layout,
			is floored by the table’s <a>min-content size</a>.
			(<a href="https://github.com/w3c/csswg-drafts/issues/2442">Issue 2442</a>)

		<li id="change-2017-break-propagation">
			Clarified that break propagation does not affect computed values
			and that <a>order-modified document order</a> is used.
			(<a href="https://github.com/w3c/csswg-drafts/issues/2614">Issue 2614</a>)
			<blockquote>
				<p>
					The exact layout of a fragmented flex container
					is not defined in this level of Flexible Box Layout.
					However, breaks inside a flex container are subject to the following rules
					<ins>(interpreted using <a>order-modified document order</a>)</ins>:

				<ul>
					<li>
						In a row flex container,
						the 'break-before' and 'break-after' values on flex items
						are propagated to the flex line.
						The 'break-before' values on the first line
						and the 'break-after' values on the last line
						are propagated to the flex container.

						<ins>

						Note: Break propagation
						(like 'text-decoration' propagation)
						does not affect <a>computed values</a>.

						</ins>
				</ul>
			</blockquote>

		<li id="change-2017-auto-min-zero">
			Clarified that if the <a>automatic minimum size</a>
			resolves directly to zero rather than being a <a>content-based minimum size</a>,
			it does not cause indefiniteness.
			<blockquote>
				<p>
					For the purpose of calculating an intrinsic size of the element
					(e.g. the element's <a>min-content size</a>),
					<del>this value</del> <ins>a content-based minimum size</ins>
					causes the element's size in that axis to become indefinite
					(even if e.g. its 'width' property specifies a <a>definite</a> size).
				</p>
			</blockquote>

		<li id="change-2017-auto-min-size">
			Editorial improvements to the <a href="#min-size-auto">automatic minimum size</a>.
			(<a href="https://github.com/w3c/csswg-drafts/issues/2385">Issue 2385</a>)

		<li>
			Some minor editorial fixes and clarifications,
			including updates to vocabulary to match updates to other CSS modules.
	</ul>

<h3 id="changes-20160526">
Changes since the 26 May 2016 CR</h3>

	A <a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-20160526">Disposition of Comments</a> is also available.

<h4 id="change-201605-substantive">
Substantive Changes and Bugfixes</h4>

	<ul>
		<li id="change-2016-box-sizing-basis">
			To allow flex factors to actually represent absolute ratios of flex item sizes
			as was originally intended (see various examples),
			removed the flooring of content-box sizes at zero
			for the purpose of finding the item’s <a>flex base size</a>,
			since this type of ratio requires a <a>flex base size</a> of zero,
			which would otherwise only be possible if margins, borders, and padding are also all zero.
			(The flooring remains in effect,
			alongside the min and max size constraints,
			in calculating the hypothetical and final sizes of the item.)
			(<a href="https://github.com/w3c/csswg-drafts/issues/316">Issue 316</a>)
			<blockquote>
				<p>
					When determining the <a>flex base size</a>,
					the item’s min and max main size properties are ignored
					(no clamping occurs).
					<ins>Furthermore, the sizing calculations that floor the content box size at zero
					when applying 'box-sizing' are also ignored.
					(For example, an item with a specified size of zero,
					positive padding, and ''box-sizing: border-box''
					will have an outer <a>flex base size</a> of zero--
					and hence a negative inner <a>flex base size</a>.)</ins>
				</p>
				<p>
					The <a>hypothetical main size</a> is the item's <a>flex base size</a>
					clamped according to its min and max main size properties
					<ins>(and flooring the content box size at zero)</ins>.
				</p>
			</blockquote>
			<blockquote>
					<strong>Fix min/max violations.</strong>
					Clamp each non-frozen item's <a>target main size</a> by its min and max main size properties
					<ins>and floor its content-box size at zero</ins>.
					If the item's <a>target main size</a> was made smaller by this,
					it's a max violation.
					If the item's <a>target main size</a> was made larger by this,
			</blockquote>
		<li id="change-2016-max-contribution">
			To prevent empty flex items in shrink-to-fit containers
			from collapsing to zero even when given a specified size,
			the specified size is now accounted for in calculating
			its <a>max-content contribution</a> in <a href="#intrinsic-item-contributions"></a>.
			(<a href="https://github.com/w3c/csswg-drafts/issues/1435">Issue 1435</a>)
			<blockquote>
				<p>The <strong>main-size <a>max-content contribution</a> of a <a>flex item</a></strong>
				is <ins>the larger of</ins> its <em>outer</em> <a>max-content size</a>
				<ins>and specified size (its 'width'/'height' as appropriate, if that is <a>definite</a>)</ins>,
				clamped by its <a>flex base size</a> as a maximum (if it is not growable)
				and/or as a minimum (if it is not shrinkable),
				and then further clamped by its <a lt="min main size property">min</a>/<a>max main size properties</a>.
			</blockquote>
		<li id="change-2016-definite-basis">
			Since at least two implementations ended up
			allowing percentages inside flex items with indefinite flex basis to resolve anyway,
			removed the condition requiring definite flex basis.
			(<a href="https://github.com/w3c/csswg-drafts/issues/1679">Issue 1679</a>)
			<blockquote>
				<p>If <del>a <a>flex item</a> has a <a>definite</a> <a>flex basis</a>
				and</del> the <a>flex container</a> has a <a>definite</a> <a>main size</a>,
				<del>its</del> <ins>a <a>flex item</a>’s</ins> post-flexing main size is treated as <a>definite</a>
				(even though it might technically rely on the <del>sizes of <a>indefinite</a> siblings to resolve its flexed main size</del>
				the <a>indefinite</a> sizes of any flex items in the same line).
			</blockquote>
		<li id="change-2016-align-self-as-specified">
			For ease of implementation, ''align-self/auto'' value of 'align-self' now computes to itself always.
			See <a href="#change-2015-align-self-auto">related previous change</a>
			requiring this computation for absolutely-positioned elements.
			(<a href="https://github.com/w3c/csswg-drafts/issues/440">Issue 440</a>,
			<a href="https://github.com/w3c/csswg-drafts/issues/644">Issue 644</a>)
			<blockquote>
				<table class="data">
				<tr><th>Computed value: <td><del><a value for=align-self>auto</a> computes to parent's 'align-items' value; otherwise</del> as specified
				</table>
				&hellip;
				<p><del>On absolutely positioned elements,
				a value of ''align-self/auto'' computes to itself.
				On all other elements, a value of ''align-self/auto'' for 'align-self'
				computes to the value of 'align-items' on the element’s parent,
				or ''align-self/stretch'' if the element has no parent.</del>
			</blockquote>
		<li id="change-2016-baseline-alignment">
			Change <a>flex items</a> in orthogonal flows and <a>flex items</a> without a baseline
			to both synthesize their alignment baseline from the <a>flex item</a>’s border box.
			(<a href="https://github.com/w3c/csswg-drafts/issues/373">Issue 373</a>)
		<li id="change-2016-main-cross-baseline">
			Fix main/cross error in definition of <a>cross-axis baseline set</a>.
			(<a href="https://github.com/w3c/csswg-drafts/issues/792">Issue 792</a>)
			<blockquote>
				<p>Otherwise, the flex container has no first/last <del>main</del><ins>cross</ins>-axis baseline set&hellip;
			</blockquote>
		<li id="change-2016-table-wrapper">
			Restore accidentally-deleted text about tables as flex items.
			See <a href="#change-2015-anonymous-fixup">anonymous box change</a>.
			(<a href="https://github.com/w3c/csswg-drafts/issues/547">Issue 547</a>)
			<blockquote>
				<ins><p>In the case of flex items with ''display: table'',
				the table wrapper box becomes the <a>flex item</a>,
				and the 'order' and 'align-self' properties apply to it.
				The contents of any caption boxes contribute to the calculation of
				the table wrapper box's min-content and max-content sizes.
				However, like 'width' and 'height', the 'flex' longhands apply to the table box as follows:
				the <a>flex item</a>’s final size is calculated
				by performing layout as if the distance between
				the table wrapper box's edges and the table box's content edges
				were all part of the table box's border+padding area,
				and the table box were the <a>flex item</a>.</p></ins>
			</blockquote>
		<li id="change-2016-auto-margin-abspos">
			Clarified that auto margins are treated as zero
			for the purpose of calculating a absolutely-positioned flex container child’s static position.
			(<a href="https://github.com/w3c/csswg-drafts/issues/665">Issue 665</a>)
			<blockquote>
				<p>For this purpose,
				a value of ''align-self: auto'' is treated identically to ''align-self/start''<ins>,
				and ''margin/auto'' margins are treated as zero</ins>.</p>
			</blockquote>
		<li id="change-2016-floor-intrinsic-size">
			When clamping by the <a>max main size property</a>
			in the <a href="#intrinsic-main-sizes">calculation of the flex container’s intrinsic size</a>,
			be sure to floor by the <a>min main size property</a>.
			(<a href="https://github.com/w3c/csswg-drafts/issues/361">Issue 361</a>)
			<blockquote>
				<p>Within each line,
				find the largest <var>max-content flex fraction</var>
				among all the <a>flex items</a>.
				Add each item’s <a>flex base size</a>
				to the product of its <a>flex grow factor</a>
				(or <a>scaled flex shrink factor</a>, if the chosen <var>max-content flex fraction</var> was negative)
				and the chosen <var>max-content flex fraction</var>,
				then clamp that result<ins>ing item size according to</ins> <del>by</del>
				the max <ins>and min</ins> main size propert<del>y</del><ins>ies</ins>.
				</p>
			</blockquote>
		<li id="change-2016-abspos-no-order-fix">
			Added missing edits for <a href="#change-2016-abspos-no-order">change</a>
			that made 'order' not apply to absolutely-positioned children of a flex container.
			(<a href="https://github.com/w3c/csswg-drafts/issues/1439">Issue 1439</a>)
			<blockquote>
				<table class="data">
					<tr><th>Applies to: <td><a>flex items</a> <del>and absolutely-positioned children of <a>flex containers</a></del>
				</table>
				<p>
					The 'order' property controls the order in which
					<del>children of a flex container</del> <ins>flex items</ins>
					appear within the flex container,
					by assigning them to ordinal groups.
					&hellip;
				</p>
				<p>
					<ins>Absolutely-positioned children of a <a>flex container</a>
					are treated as having ''order: 0''
					for the purpose of determining their painting order relative to <a>flex items</a>.</ins>
				</p>
			</blockquote>
			<blockquote>
				Unless otherwise specified by a future specification,
				this property has no effect on boxes that are not
				<del>children of a <a>flex container</a></del> <ins><a>flex items</a></ins>.
			</blockquote>
		<li id="change-2016-flex-direction-baseline">
			Take 'flex-direction' into account when determining first/last baseline of the flex container.
			(<a href="https://github.com/w3c/csswg-drafts/issues/995">Issue 995</a>)
			<blockquote>
				<p>
					To this end,
					the baselines of a flex container are determined as follows
					(after reordering with 'order'<ins>,
					and taking 'flex-direction' into account</ins>):
				</p>
				<p>&hellip;</p>
				<ol>
					<li>
						If any of the <a>flex items</a> on the flex container's
						<del>first/last</del> <ins>startmost/endmost</ins> <a>flex line</a>
						<a href="#baseline-participation">participate in baseline alignment</a>,
						the flex container's first/last <a>main-axis baseline set</a> &hellip;
					<li>
						Otherwise, if the flex container has at least one <a>flex item</a>,
						the flex container's first/last <a>main-axis baseline set</a>
						is <a lt="generate baselines">generated</a> from
						the <a>alignment baseline</a> of the
						<del>first/last</del> <ins>startmost/endmost</ins> <a>flex item</a>.
						&hellip;
					<li>
						Otherwise, the flex container has no first/last main-axis <a>baseline set</a>, &hellip;
				</ol>
				<p>&hellip;</p>
				<ol>
					<li>
						If the flex container has at least one <a>flex item</a>,
						the flex container's first/last <a>cross-axis baseline set</a>
						is <a lt="generate baselines">generated</a> from
						the <a>alignment baseline</a> of the
						<del>first/last</del> <ins>startmost/endmost</ins> <a>flex item</a>.
						&hellip;
				</ol>
			</blockquote>
		<li id="change-2016-space-between-single-line">
			Define ''align-content: space-between'' handling of a single <a>flex line</a>
			as equivalent to ''align-content/start''.
			(<a href="https://github.com/w3c/csswg-drafts/issues/718">Issue 718</a>)
			<blockquote>
				<p>
					Lines are evenly distributed in the flex container.
					If the leftover free-space is negative
					<ins>or there is only a single <a>flex line</a> in the flex container,</ins>
					this value is identical to <a value for=align-content>flex-start</a>.
			</blockquote>
		<li id="change-2016-axis-error">
			Fixed error in <a href="#axis-mapping">axis mapping table</a>.
			(<a href="https://github.com/w3c/csswg-drafts/issues/205">Issue 205</a>)
		<li id="change-2016-reword-min-auto-fix">
			Restored definition of the <a>automatic minimum size</a>
			of boxes with neither <a>specified size</a> nor aspect ratio,
			which was lost in earlier <a href="#change-2016-reword-min-auto">rewrite</a>.
			(<a href="https://github.com/w3c/csswg-drafts/issues/671">Issue 671</a>)
	</ul>

<h4 id="change-201605-clarify">
Clarifications</h4>
	<ul>
		<li id="change-2016-main-cross-def">
			Made sure that <a>main size</a> and <a>cross size</a> are defined
			for <a>flex containers</a> as well as for <a>flex items</a>.
			(<a href="https://github.com/w3c/csswg-drafts/issues/981">Issue 981</a>)
		<li id="change-2016-broken-spatial-note">
			Tweaked final clarifying sentence of note about spatial navigation.
			(<a href="https://github.com/w3c/csswg-drafts/issues/1677">Issue 1677</a>)
			<blockquote>
				<p class="note">
					User agents, including browsers, accessible technology, and extensions,
					may offer spatial navigation features.
					This section does not preclude respecting the 'order' property
					when determining element ordering in such spatial navigation modes;
					indeed it would need to be considered for such a feature to work.
					<del>However a UA that uses 'order' in determining sequential navigation,
					but does not otherwise account for spatial relationships among elements
					(as expressed by the various layout features of CSS including and not limited to flex layout),
					is non-conforming.</del>
					<ins>But 'order' is not the only (or even the primary) CSS property
					that would need to be considered for such a spatial navigation feature.
					A well-implemented spatial navigation feature would need to consider
					all the layout features of CSS that modify spatial relationships.</ins>
			</blockquote>
		<li>Miscellaneous trivial editorial improvements.
	</ul>

<h3 id="changes-20160301">
Changes since the 1 March 2016 CR</h3>

	A <a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-20160301">Disposition of Comments</a> is also available.

<h4 id="change-201603-substantive">
Substantive Changes and Bugfixes</h4>

	<ul>
		<li id="change-2016-intrinsic-percentage">
			Define how percentages are handled when calculating intrinsic <a>automatic minimum sizes</a>.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-20160301#issue-3">Issue 3</a>)
			<blockquote>
				<ins><p>
					For the purpose of calculating an intrinsic size of the element
					(e.g. the element's <a>min-content size</a>),
					this value causes the element's size in that axis to become indefinite
					(even if e.g. its 'width' property specifies a <a>definite</a> size).
					Note this means that percentages calculated against this size
					will be treated as ''height/auto''.
				</p></ins>

				<p>
					<ins>Nonetheless,</ins>
					although this may require an additional layout pass to re-resolve percentages in some cases,
					this value
					(like the ''min-content'', ''max-content'', and ''fit-content'' values defined in [[CSS-SIZING-3]])
					does not prevent the resolution of percentage sizes within the item.
				</p>
			</blockquote>
		<li id="change-2016-definite-indefinite">
			Switched <a>definite</a> and <a>indefinite</a> to refer to the (more correct) definitions in [[!CSS-SIZING-3]]
			instead of defining them inline in this module.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-20160301#issue-10">Issue 10</a>)
		<li id="change-2016-abspos-no-order">
			Abspos children of a flexbox no longer respond to the 'order' property.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-20160301#issue-12">Issue 12</a>)
		<li id="change-2016-baseline-sets">
			Updated <a href="#flex-baselines"></a>
			to account for <a>baseline sets</a> and <a>last-baseline alignment</a>.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-20160301#issue-13">Issue 13</a>))
	</ul>

<h4 id="change-201603-clarify">
Clarifications</h4>

	<ul>
		<li id="change-2016-spatial-nav">
			Clarify that spatial navigation modes are allowed to handle 'order'.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-20160301#issue-1">Issue 1</a>)
			<blockquote>
				<ins><p class="note">
					User agents, including browsers, accessible technology, and extensions,
					may offer spatial navigation features.
					This section does not preclude respecting the 'order' property
					when determining element ordering in such spatial navigation modes;
					indeed it would need to be considered for such a feature to work.
					However a UA that uses 'order' in determining sequential navigation,
					but does not otherwise account for spatial relationships among elements
					(as expressed by the various layout features of CSS including and not limited to flex layout),
					is non-conforming.
			 </p></ins>
			</blockquote>
		<li id="change-2016-definite-3">
			Cross-reference an additional case of definiteness in <a href="#definite-sizes"></a>
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-20160301#issue-2">Issue 2</a>)
			<blockquote>
				<ins><p>
					Once the cross size of a flex line has been determined,
					items in auto-sized flex containers are also considered
					definite for the purpose of layout; see <a href="#algo-stretch">step 11</a>.
				</p></ins>
			</blockquote>
		<li id="change-2016-auto-content-wording">
			Improve wording for how unresolveable percentage <a>flex basis</a> values
			transmute to ''content''.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-20160301#issue-6">Issue 6</a>)
			<blockquote>
				<p>
					For all values other than ''flex-basis/auto'' and ''content'' (defined above),
					'flex-basis' is resolved the same way as 'width' in horizontal writing modes [[!CSS2]],
					<ins>except that if a value would resolve to ''width/auto'' for 'width',
					it instead resolves to ''content'' for 'flex-basis'</ins>.
					For example, percentage values of 'flex-basis' are resolved against
					the flex item's containing block (i.e. its <a>flex container</a>);
					and if that containing block's size is <a>indefinite</a>,
					<del>the result is the same as a <a>main size</a> of <a value for=width>auto</a>
					(which in this case is treated as ''content'')</del>
					<ins>the used value for 'flex-basis' is ''content''</ins>.
				</p>
			</blockquote>
		<li id="change-2016-inflexible-definite">
			Clarify that inflexible items with a <a>definite</a> <a>flex basis</a> have a <a>definite size</a>.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-20160301#issue-8">Issue 8</a>,
			 <a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-20160301#issue-11">Issue 11</a>)
			<blockquote>
				<ins>
					<p>A <a>flex item</a> is <a>fully inflexible</a>
					if both its 'flex-grow' and 'flex-shrink' values are zero,
					and <a>flexible</a> otherwise.</p>
				</ins>
			</blockquote>
			<blockquote>
				<ins><p class="note">
					The main size of a <a>fully inflexible</a> item with a <a>definite</a> <a>flex basis</a>
					is, by definition, <a>definite</a>.
				</p></ins>
			</blockquote>
		<li id="change-2016-reword-min-auto">
			Reworded definition of the ''min-width/auto'' value to be easier to understand.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-20160301#issue-9">Issue 9</a>)
			<blockquote>
				<p>
					On a <a>flex item</a> whose 'overflow' is ''overflow/visible'' in the <a>main axis</a>,
					when specified on the <a>flex item's</a> main-axis min-size property,
					<del>the following table gives the minimum size &hellip;</del>
					<ins>specifies an <a>automatic minimum size</a>.</ins>
				</p>
				<ins><p>
					In general, the <a>automatic minimum size</a> &hellip; defined below:
				</p></ins>
			</blockquote>
		<li id="change-2016-clarify-staticpos">
			Slightly reworded the section on determining the static position of absolutely-positioned children to be clearer.
		<li id="change-2016-animation-type">
			Adjusted format of Animatable lines to be clearer about animating keywords.
		<li>Miscellaneous trivial editorial improvements.
	</ul>


<h3 id="changes-201505">
Changes since the 14 May 2015 LCWD</h3>

	A <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20150514">Disposition of Comments</a> is also available.

<h4 id="change-201505-substantive">
Substantive Changes and Bugfixes</h4>

	<ul>
		<li id="change-2015-flex-basis-zero">
			Revert 'flex' shorthand <a href="#change-2012-flex-basis-zero">change</a>
			of omitted 'flex-basis' back to ''0'',
			since that was a hacky way of solving an intrinsic size problem,
			and isn't needed (and gives bad results)
			given a correct implementation of [[#intrinsic-sizes]].
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20150514#issue-13">Issue 13</a>)
			<blockquote>
				<p>When omitted from the 'flex' shorthand, its specified value is ''0<del>%</del>''.
			</blockquote>
			<blockquote>
				<dl>
					<dt>''flex: &lt;positive-number>''
					<dd>
						Equivalent to ''flex: &lt;positive-number> 1 0<del>%</del>''.
				</dl>
			</blockquote>
		<li id="change-2015-anonymous-fixup">
			Changed <a href="#flex-item">flex item determination</a> to operate on each element directly,
			and not on its anonymous wrapper box, if any.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20150514#issue-6">Issue 6</a>)
			<blockquote>
				<ul>
					<li><del>'float' and 'clear' have no effect on a <a>flex item</a>,</del>
					    <ins>'float' and 'clear' do not create floating or clearance of <a>flex item</a>,</ins>
					    and do not take it out-of-flow.
					    <del>However, the 'float' property can still affect box generation
					    by influencing the 'display' property's computed value.</del>
				</ul>
			</blockquote>
			<blockquote>
				<del>
					<p>Some values of 'display' trigger the creation of anonymous boxes around the original box.
					It's the outermost box&mdash;the direct child of the <a>flex container</a> box&mdash;that
					becomes a <a>flex item</a>.
					For example, given two contiguous child elements with ''display: table-cell'',
					the <a href="https://www.w3.org/TR/CSS2/tables.html#anonymous-boxes">anonymous table wrapper box generated around them</a> [[!CSS2]]
					becomes the <a>flex item</a>.</p>
					<p>In the case of flex items with ''display: table'',
					the table wrapper box becomes the <a>flex item</a>,
					and the 'order' and 'align-self' properties apply to it.
					The contents of any caption boxes contribute to the calculation of
					the table wrapper box's min-content and max-content sizes.
					However, like 'width' and 'height', the 'flex' longhands apply to the table box as follows:
					the <a>flex item</a>’s final size is calculated
					by performing layout as if the distance between
					the table wrapper box's edges and the table box's content edges
					were all part of the table box's border+padding area,
					and the table box were the <a>flex item</a>.</p>
				</del>
				<ins>
					<p class="note">
					Note: Some values of 'display' normally trigger the creation of anonymous boxes around the original box.
					If such a box is a <a>flex item</a>,
					it is blockified first,
					and so anonymous box creation will not happen.
					For example, two contiguous <a>flex items</a> with ''display: table-cell''
					will become two separate ''display: block'' <a>flex items</a>,
					instead of being wrapped into a single anonymous table.</p>
				</ins>
			</blockquote>
		<li id="change-2015-min-auto-intrinsic-percentages">
			Defined that any size adjustment imposed by a box’s ''min-height/min-width: auto''
			is consulted when percentage-sizing any of its contents.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20150514#issue-3">Issue 3</a>)
			<blockquote>
				<p><del>In order to prevent cycling sizing,
				the ''auto'' value of 'min-height' and 'max-height'
				does not factor into the percentage size resolution of the box’s contents.
				For example, a percentage-height block whose flex item parent has
				''height: 120em; min-height: auto''
				will size itself against ''height: 120em'' regardless of the impact
				that 'min-height' might have on the used size of the flex item.</del>
				<p><ins>Although this may require an additional layout pass to re-resolve percentages in some cases,
				the ''min-width/auto'' value of 'min-width' and 'min-height'
				(like the ''min-content'', ''max-content'', and ''fit-content'' values defined in [[CSS-SIZING-3]])
				does not prevent the resolution of percentage sizes within the item.</ins>
			</blockquote>
		<li id="change-2015-intrinsic-items">
			Correct intrinsic sizing rules to handle inflexible items.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20150514#issue-1">Issue 1</a>)
			<blockquote>
				<p>The main-size <a lt="min-content contribution">min-content</a>/<a>max-content contribution</a> of a <a>flex item</a>
					is its outer <del><a>hypothetical main size</a>
					when sized under a <a lt="min-content constraint">min-content</a>/<a>max-content constraint</a> (respectively)</del>
					<ins>The <strong>main-size <a lt="min-content contribution">min-content</a>/<a>max-content contribution</a> of a <a>flex item</a></strong>
					is its <em>outer</em> <a lt="min-content size">min-content</a>/<a>max-content size</a>,
					clamped by its <a>flex base size</a> as a maximum (if it is not growable)
					and/or as a minimum (if it is not shrinkable),
					and then further clamped by its <a lt="min main size property">min</a>/<a>max main size properties</a></ins>.</p>
			</blockquote>
		<li id="change-2015-intrinsic-main-container">
			Correct errors in <a>flex container</a> main-axis intrinsic sizing.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20150514#issue-1">Issue 1</a>)
			<blockquote>
				<p>The <a>max-content</a> <a>main size</a> of a <a>flex container</a>
				is the smallest size the <a>flex container</a> can take
				while maintaining the <a>max-content contributions</a> of its <a>flex items</a>:</p>
					<ol>
					<li>
							For each <a>flex item</a>,
							subtract its <ins>outer</ins> <a>flex base size</a> from its <a>max-content contribution</a> size<del>,
							then divide by its <a>flex grow factor</a>, floored at 1,
							or by its <a>scaled flex shrink factor</a> (if the result was negative,
							flooring the <a>flex shrink factor</a> at 1 if necessary)</del>.
							<ins>If that result is not zero, divide it by (if the result was positive) its <a>flex grow factor</a> floored at 1,
							or (if the result was negative) by its <a>scaled flex shrink factor</a>, having floored the <a>flex shrink factor</a> at 1.</ins>
							This is the item's <var>max-content flex fraction</var>.
					</ol>
			</blockquote>
		<li id="change-2015-intrinsic-cross-container">
			Correct errors in <a>flex container</a> cross-axis intrinsic sizing,
			and specify commonly-implemented min-content sizing heuristic for multi-line column flex containers.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20150514#issue-12">Issue 12</a>)
			<blockquote>
				<del>
					<p>The <a>min-content</a> <a>cross size</a> and  <a>max-content</a> <a>cross size</a> of a flex container
					are the <a>cross size</a> of the flex container
					after performing layout into the given available <a>main-axis</a> space and infinite available <a>cross-axis</a> space.</p>
				</del>

				<ins>
					<p>The <a>min-content</a>/<a>max-content</a> <a>cross size</a> of a <em><a>single-line</a></em> <a>flex container</a>
					is the largest <a>min-content contribution</a>/<a>max-content contribution</a> (respectively)
					of its <a>flex items</a>.</p>

					<p>For a <em><a>multi-line</a></em> <a>flex container</a>,
					the <a>min-content</a>/<a>max-content</a> <a>cross size</a>
					is the sum of the flex line cross sizes
					resulting from sizing the flex container under a <a>cross-axis</a> <a>min-content constraint</a>/<a>max-content constraint</a> (respectively).
					However, if the <a>flex container</a> is ''flex-flow: column wrap;'',
					then it's sized by first finding the largest
					<a lt="min-content contribution">min-content</a>/<a lt="min-content contribution">max-content</a>
					cross-size contribution among the <a>flex items</a> (respectively),
					then using that size as the <a>available space</a> in the <a>cross axis</a>
					for each of the <a>flex items</a> during layout.</p>

					<p class="note">This heuristic for ''column wrap'' <a>flex containers</a>
					gives a reasonable approximation of the size that the <a>flex container</a> should be,
					with each flex item ending up as min(<var>item’s own max-content</var>, <var>maximum min-content among all items</var>),
					and each <a>flex line</a> no larger than its largest <a>flex item</a>.
					It's not a <em>perfect</em> fit in some cases,
					but doing it completely correct is insanely expensive,
					and this works reasonably well.</p>
				</ins>
			</blockquote>
		<li id="change-2015-a11y-tools">
			Add explicit conformance criteria on authoring tools
			to keep presentation and DOM order in sync
			unless author explicitly indicates a desire to make them out-of-sync.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20150514#issue-8">Issue 8</a>)
			<blockquote>
				<ins>
					<p>In order to preserve the author's intended ordering in all presentation modes,
					authoring tools&mdash;including WYSIWYG editors as well as Web-based authoring aids--
					must reorder the underlying document source
					and not use 'order' to perform reordering
					unless the author has explicitly indicated that the underlying
					document order (which determines speech and navigation order) should be
					<em>out-of-sync</em> with the visual order.</p>

					<div class="example" id="example-a11y-tools">
						For example, a tool might offer both drag-and-drop reordering of flex items
						as well as handling of media queries for alternate layouts per screen size range.

						Since most of the time, reordering should affect all screen ranges
						as well as navigation and speech order,
						the tool would perform drag-and-drop reordering at the DOM layer.
						In some cases, however, the author may want different visual orderings per screen size.
						The tool could offer this functionality by using 'order' together with media queries,
						but also tie the smallest screen size's ordering to the underlying DOM order
						(since this is most likely to be a logical linear presentation order)
						while using 'order' to determine the visual presentation order in other size ranges.

						This tool would be conformant, whereas a tool that only ever used 'order'
						to handle drag-and-drop reordering
						(however convenient it might be to implement it that way)
						would be non-conformant.
					</div>
				</ins>
			</blockquote>
		<li id="change-2015-align-self-auto">
			Defined that an 'align-self' or 'justify-self' value of ''align-self/auto''
			computes to itself on absolutely-positioned elements,
			for consistency with future extensions of these properties in [[CSS-ALIGN-3]].
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20150514#issue-5">Issue 5</a>)
			<blockquote>
				<p>
					<ins>On absolutely positioned elements,
					a value of ''align-self/auto'' computes to itself.
					On all other elements, a</ins> <del>A</del> value of ''align-self/auto'' for 'align-self'
					computes to the value of 'align-items' on the element’s parent,
					or ''align-self/stretch'' if the element has no parent.
				</p>
			</blockquote>
		<li id="change-2015-percentage-margins">
			Revert change to make percentage margins and padding relative to their own axes;
			instead allow both behaviors.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20150514#issue-11">Issue 11</a>,
			 <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20150514#issue-16">Issue 16</a>)
			<blockquote>
				<del>
					<p>Percentage margins and paddings on <a>flex items</a> are always resolved against their respective dimensions;
					unlike blocks, they do not always resolve against the inline dimension of their containing block.</p>
				</del>
				<ins>
					<p>Percentage margins and paddings on <a>flex items</a> can be resolved against either:</p>
					<ul>
						<li>their own axis (left/right percentages resolve against width, top/bottom resolve against height), or,
						<li>the inline axis (left/right/top/bottom percentages all resolve against width)
					</ul>
					<p>A user agent must choose one of these two behaviors.</p>

					<p class="note">Note: This variance sucks, but it accurately captures the current state of the world
					(no consensus among implementations, and no consensus within the CSSWG).
					It is the CSSWG's intention that browsers will converge on one of the behaviors,
					at which time the spec will be amended to require that.</p>

					<p class="advisement">Authors should avoid using percentages in paddings or margins on <a>flex items</a> entirely,
					as they will get different behavior in different browsers.</p>
				</ins>
			</blockquote>
		<li id="change-2015-min-max-constraint">
			Handle min/max constraints in sizing flex items.
			<blockquote>
				<ul>
					<li>
						<strong>Determine the available main and cross space for the flex items.</strong>
						For each dimension,
						if that dimension of the <a>flex container</a>’s content box is a <a>definite size</a>, use that;
						<ins>if that dimension of the <a>flex container</a> is being sized under a <a lt="min-content constraint">min</a> or <a>max-content constraint</a>,
						the available space in that dimension is that constraint;</ins>
						otherwise, subtract the <a>flex container</a>’s margin, border, and padding
						from the space available to the flex container in that dimension
						and use that value.
				</ul>
			</blockquote>
		<li id="changes-2015-first-fragment">
			Correct negation in flex container fragmentation rule:
			previous definition implied ''break-inside: avoid'' behavior in all cases.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20150514#issue-5">Issue 5</a>)
			<blockquote>
				<ul>
					<li>
						If the first fragment of the flex container is not at the top of the page,
						and <del>some</del><ins>none</ins> of its flex items <del>don't</del> fit in the remaining space on the page,
						the entire fragment is moved to the next page.
				</ul>
			</blockquote>
	</ul>

<h4 id="change-201505-clarify">
Clarifications</h4>

	<ul>
		<li>Miscellaneous minor editorial improvements and fixes to errors in examples.
	</ul>

<h3 id="changes-201409">
Changes since the 25 September 2014 LCWD</h3>

	A <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140925">Disposition of Comments</a> is also available.

<h4 id="change-201409-substantive">
Substantive Changes and Bugfixes</h4>

	<ul>
		<li id="change-201409-content">
			Reverted ''flex-basis: auto'' to its original meaning.
			Added ''flex-basis: content'' keyword to explicitly specify automatic content-based sizing.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140925#issue-10">10</a>)

		<li id="change-201409-align-content-wrapping">
			Made applicability of 'align-content' depend on wrappability rather than number of resulting flex lines.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140925#issue-4">4</a>)

			<blockquote>
				<p><del>When a flex container has multiple lines,</del>
				<ins>In a <a>multi-line</a> <a>flex container</a> (even one with only a single line),</ins>
				the <a>cross size</a> of each line is the minimum size necessary [...]
				<del>When a flex container (even a <a>multi-line</a> one) has only one line,</del>
				<ins>In a <a>single-line</a> <a>flex container</a>,</ins>
				the <a>cross size</a> of the line is the <a>cross size</a> of the flex container,
				and 'align-content' has no effect.
			</blockquote>

			<blockquote>
				<p class="note">Note, this property has no effect
				<del>when the flex container has only a single line.</del>
				<ins>on a <a>single-line</a> <a>flex container</a>.</ins>
			</blockquote>

			<blockquote>
				<p class="note">Only <del>flex containers with multiple lines</del>
				<ins><a>multi-line</a> <a>flex containers</a></ins>
				ever have free space in the <a>cross-axis</a> for lines to be aligned in,
				because in a <del>flex container with a single line</del>
				<ins><a>single-line</a> flex container</ins>
				the sole line automatically stretches to fill the space.
			</blockquote>

			<blockquote>
				<p>If the flex container <del>has only one <a>flex line</a>
				(even if it's a <a>multi-line</a> <a>flex container</a>)</del>
				<ins>is <a>single-line</a></ins>
				and has a <a>definite</a> <a>cross size</a>,
				the <a>cross size</a> of the <a>flex line</a>
				is the <a>flex container</a>'s inner <a>cross size</a>.
			</blockquote>

			<blockquote>
				<p>If the flex container <del>has only one flex line
				(even if it's a multi-line flex container),</del>
				<ins>is <a>single-line</a>,</ins>
				then clamp the line's <a>cross size</a> to be within the container's computed min and max cross-size properties.
			</blockquote>

		<li id="change-201409-algo-breaks">
			Removed text that asserted forced breaking behavior,
			replaced with reference to fragmentation section.
			This resolves a conflict in the spec.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140925#issue-18">18</a>)

			<blockquote>
				<p>collect consecutive items one by one
				until the first time that the next collected item would not fit into the flex container’s inner main size,
				<ins>(</ins>or until a forced break is encountered<ins>, see [[#pagination]])</ins>.
				[...]
				<del>A break is forced wherever the CSS2.1 'page-break-before'/'page-break-after' [[CSS2]]
				or the CSS3 'break-before'/'break-after' [[CSS3-BREAK]] properties specify a fragmentation break.</del></p>
			</blockquote>

		<li id="change-201409-inner-base-size">
			Change the <a>flex shrink factor</a> to multiply by the  <em>inner</em> (not outer) <a>flex base size</a>.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140925#issue-9">9</a>)

			<blockquote>
				<p>For every unfrozen item on the line,
				multiply its flex shrink factor by its <del>outer</del> <ins>inner</ins> flex base size,
				and note this as its <a>scaled flex shrink factor</a>.
			</blockquote>

		<li id="change-201409-neither">
			Add back in missing “n” in “neither”...
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140925#issue-6">6</a>)

			<blockquote>
				<p>If the <a>cross size property</a> of the <a>flex item</a> computes to ''width/auto'',
				and <ins>n</ins>either of the <a>cross-axis</a> margins are ''margin/auto'',
				the <a>flex item</a> is <a>stretched</a>.
			</blockquote>

		<li id="change-201409-flexed-definite-container">
			Specify that the <a>flex container</a>’s <a>main size</a> must also be <a>definite</a>
			for a flex item’s flexed main size to be <a>definite</a>.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140925#issue-20">20</a>)

			<blockquote>
				<p>[If] ... the <a>flex item</a> has a <a>definite</a> <a>flex basis</a>,
				<ins>and the <a>flex container</a> has a <a>definite</a> <a>main size</a>,</ins>
				the <a>flex item’s</a> <a>main size</a> must be treated as <a>definite</a> ...
			</blockquote>

		<li id="change-201409-min-auto-specified-size">
			Remove the requirement that the <a>flex basis</a> be ''content'' for the <a>specified size</a> to be defined.
			The specified size should always win if it is smaller than the intrinsic size.
			This is particularly important to maintain author expectations for,
			e.g. <code>&lt;img src="&hellip;" width=40 height=40 title="100x100 image"&gt;</code>.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140925#issue-25">25</a>)

			<blockquote>
				If the item’s <del>computed 'flex-basis' is ''content''
				and its</del> computed <a>main size property</a> is <a>definite</a>,
				then the <a>specified size</a> is that size
			</blockquote>

		<li id="change-2014-blockify">
			Remove the requirement that anonymous block creation (for things like ''display: table-cell'')
			occur <em>before</em> <a>flex item</a> blockification.
			(Instead, all children now blockify immediately,
				consistent with abspos/float behavior.)
	</ul>

<h4 id="change-201409-clarify">
Clarifications</h4>

	<ul>
		<li id="change-201409-unclamped-size">
			Clarify that <a>flex base size</a> is unclamped.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140925#issue-21">21</a>)

			<blockquote>
				<p><ins>When determining the <a>flex base size</a>,
				the item’s min and max main size properties are ignored
				(no clamping occurs).</ins>
				<p>The <a>hypothetical main size</a> is the item's <a>flex base size</a>
				clamped according to its min and max main size properties.
			</blockquote>

		<li id="change-201409-table-wrappers">
			Restored normative status of note about table wrapper boxes normative;
			it had been accidentally changed in the previous draft.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140925#issue-2">2</a>)

		<li id="change-201409-display-longhands">
			Removed references to 'display' property longhands,
			since they will be removed from CSS Display Level 3.

		<li id="change-201409-layout-vs-size">
			Change wording to not imply an unnecessary layout pass.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140925#issue-22">22</a>)

			<blockquote>
				Otherwise,
				<del>lay out</del><ins>size</ins> the item into the <a>available space</a>
				using its used <a>flex basis</a> in place of its <a>main size</a>,
				treating a value of ''content'' as ''width/max-content''.
			</blockquote>

		<li id="change-201409-clamped-specified">
			Renamed “clamped size” to “specified size” in the definition of ''min-width/height: auto''.

		<li>
			Various trivial fixes.
	</ul>

<h3 id="changes-201403">
Changes since the 25 March 2014 LCWD</h3>

	A <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325">Disposition of Comments</a> is also available.

<h4 id="change-201403-substantive">
Substantive Changes and Bugfixes</h4>

	The following significant changes were made since the
	<a href="https://www.w3.org/TR/2014/WD-css-flexbox-1-20140325/">25 March 2014 Last Call Working Draft</a>

	<ul>
		<li id="change-201403-min-auto-not">
			Fixed errors (missing negation, unspecified axis) in definition of ''min-height/min-width: auto''.
			(Issues <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-11">11</a>,
			<a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-18">18</a>,
			<a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-30">30</a>)

			<blockquote>
				<p>On a <a>flex item</a> whose 'overflow' is <del>not</del> ''overflow/visible'' <ins>in the <a>main axis</a></ins>,
			</blockquote>

		<li id="change-201403-min-auto-ratio">
			Expanded and rewrote definition of ''min-height/min-width: auto''
			to add special handling of items with intrinsic ratios.
			(Issues <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-16">16</a>
			and <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-28">28</a>)

			<blockquote>
				<p>On a <a>flex item</a> whose 'overflow' is not ''overflow/visible'',
				<ins>the following table gives the minimum size:
				<a value for="min-width" lt="auto"><strong>[see table]</strong></a></ins><br>
				<del>this keyword specifies as the minimum size the smaller of:</del></p>
				<del>
					<ul>
						<li>the <a>min-content size</a>, or
						<li>the computed 'width'/'height', if that value is <a>definite</a>.
					</ul>
				</del>
			</blockquote>

		<li id="change-201403-min-auto-main-size-basis">
			Adjusted ''min-height/min-width: auto''
			to only apply the computed main size as a minimum
			in cases where the flex basis was retrieved from the main size property.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-19">19</a>)

			<blockquote>
				<p>&hellip; is defined if <ins>the item’s computed flex-basis is ''auto'' and</ins>
				its computed main size property is definite &hellip;
			</blockquote>

		<li id="change-201403-min-auto-intrinsic-percentages">
			Defined that any size adjustment imposed by a box’s ''min-height/min-width: auto''
			is not consulted when percentage-sizing any of its contents.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-27">27</a>)
			This change was later reverted with an <a href="#change-2015-min-auto-intrinsic-percentages">opposite definition</a>.
			<blockquote>
				<p>In order to prevent cycling sizing,
				the ''auto'' value of 'min-height' and 'max-height'
				does not factor into the percentage size resolution of the box’s contents.
				For example, a percentage-height block whose flex item parent has
				''height: 120em; min-height: auto''
				will size itself against ''height: 120em'' regardless of the impact
				that 'min-height' might have on the used size of the flex item.
			</blockquote>

		<li id="change-201403-flex-basis-auto">
			Introduced extra ''main-size'' keyword to 'flex-basis'
			so that “lookup from main-size property” and “automatic sizing” behaviors
			could each be explicitly specified.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-20">20</a>)
			This change was later reverted with an alternative proposal solving the same problem
			by instead introducing the ''content'' keyword.

		<li id="change-201403-definite-flexing">
			Defined <a>flex items</a> with a <a>definite</a> <a>flex basis</a>
			to also be <a>definite</a> in the <a>main axis</a>,
			allowing resolution of percentage-sized children
			even when the item itself is flexible.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-26">26</a>)

			<blockquote>
				<ins><p>If a percentage is going to be resolved against a flex item’s main size,
				and the flex item has a definite flex basis,
				the main size must be treated as definite for the purpose of resolving the percentage,
				and the percentage must resolve against the flexed main size of the flex item
				(that is, after the layout algorithm below has been completed for the flex item’s flex container,
				and the flex item has acquired its final size).</p>
				</ins>
			</blockquote>

		<li id="change-201403-clamp-single-line">
			Clamp a single line flexbox's line <a>cross size</a> to the container's own min/max,
			even when the container's size is indefinite.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-9">9</a>)

			<blockquote>
				<ul>
					<li>
						The used <a>cross size</a> of the <a>flex line</a> is
						the largest of the numbers found in the previous two steps
						and zero.

						<p><ins>If the flex container has only one flex line
						(even if it's a multi-line flex container),
						then clamp the line's <a>cross size</a> to be within the container's computed min and max cross-size properties.
						<span class='note'>Note that if CSS 2.1's definition of min/max-width/height applied more generally,
						this behavior would fall out automatically.</span></ins>
				</ul>
			</blockquote>

		<li id="change-201403-resolve-flex">
			Fixed various errors in the new <a href="#resolve-flexible-lengths">Resolving Flexible Lengths</a> section
			(see <a href="#change-2012-flex-continuity">March 2014 rewrite to create continuity between <css>flex: 0</css> and <css>flex: 1</css></a>)
			and reverted the editorial structure to match the old Candidate Recommendation.
			(Issues <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-3">3</a>,
			 <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-4">4</a>,
			  <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-8">8</a>,
			  <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-10">10</a>,
			  <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-15">15</a>)

		<li id="change-201403-max-intrinsic">
			Fixed <a href="#intrinsic-sizes">max-content sizing of flex containers</a>
			to account for flexing behavior
			by normalizing per flex fraction rather than merely summing the max-content sizes of the flex items.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-39">39</a>)

		<li id="change-201403-flex-animation">
			Updated 'flex' property to accept animations always,
			now that the discontinuity between 0 and non-0 values has been <a href="#change-2012-flex-continuity">fixed</a>.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-5">5</a>)
	</ul>

<h4 id="change-201403-clarify">
Clarifications</h4>

	The following significant changes were made since the
	<a href="https://www.w3.org/TR/2014/WD-css-flexbox-1-20140325/">25 March 2014 Last Call Working Draft</a>

	<ul>
		<li id="change-201403-css21-staticpos">
			Clarified how the static position of an absolutely-positioned child of a flex container
			is calculated by introducing an explanation of the effect more closely tied
			with CSS2.1 concepts and terminology.
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-12">12</a>)

			<blockquote>
				<p><del>Its</del> <ins>The</ins> static position <ins>of an absolutely-positioned child of a flex container</ins>
				is <del>calculated by first doing full flex layout without the absolutely-positioned children,
				then positioning each absolutely-positioned child</del>
				<ins>determined such that the child is positioned</ins>
				as if it were the sole flex item in the flex container,
				assuming both the child and the flex container were fixed-size boxes of their used size.

				<p><ins>In other words, the static position of an absolutely positioned child of a flex container
				is determined <em>after flex layout</em>
				by setting the child’s <a>static-position rectangle</a> to the flex container’s content box,
				then aligning the absolutely positioned child within this rectangle
				according to the 'justify-content' value of the flex container and the 'align-self' value of the child itself.</ins>
			</blockquote>

		<li id="change-201403-abspos-ordering">
			Clarified application of 'order' to absolutely-positioned children of the <a>flex container</a>.
			(Note, this behavior was later <a href="#change-2016-abspos-no-order">rescinded</a>.)

			<blockquote>
				<p>An absolutely-positioned child of a flex container does not participate in flex layout
				<del>beyond the reordering step</del>.
				<ins>However, it does participate in the reordering step (see 'order'),
				which has an effect in their painting order.</ins>
			</blockquote>

			<blockquote>
				<p>The order property controls the order in which <del>flex items</del>
				<ins>children of a flex container</ins>
				appear within their flex container&hellip;
				<p>Unless otherwise specified by a future specification,
				this property has no effect on boxes that are not <del>flex items</del>
				<ins>children of a flex container</ins>.
			</blockquote>

			<blockquote>
				<ins><p class="note">Note: Absolutely-positioned children of a flex container
				do not participate in flex layout, but are reordered
				together with any flex item children.</p></ins>
			</blockquote>

		<li id="change-201403-clarify-stretched">
			Clarified what a <a>stretched</a> flex item is
			for the purposes of special behavior (like definiteness).
			(Issue <a href="https://drafts.csswg.org/css-flexbox-1/issues-lc-20140325#issue-25">25</a>)
			<blockquote>
				<p>If the <a>cross size</a> property of the flex item computes to auto,
				<ins>and either of the cross-axis margins are auto, the flex item is stretched. Its</ins>
				<del>its</del> used value &hellip;
			</blockquote>
	</ul>

<h3 id="changes-2012">
Changes since the 18 September 2012 Candidate Recommendation</h3>

	A <a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012">Disposition of Comments</a> is also available.

<h4 id="changes-2014-substantive">
Substantive Changes and Bugfixes</h4>

	The following significant changes were made since the
	<a href="https://www.w3.org/TR/2012/CR-css3-flexbox-20120918/">18 September 2012 Candidate Recommendation</a>:

	<ul>
	<!-- Apparently we forgot to actually edit in this change. See above.
		<li id="change-2012-flex-grow-animation">
			Removed the restriction on animating between 0 and non-0 values in 'flex-grow' and 'flex-shrink',
			as the layout algo no longer has a discontinuity in behavior there.
	-->
		<li id="change-2012-min-width">
			Changed the behavior of the new ''min-width/auto'' initial value of 'min-width'/'min-height' to
			<ul>
				<li>Take into account whether 'overflow' is ''overflow/visible'',
					since when 'overflow' is explicitly handled, it is confusing (and unnecessary)
					to force enough size to show all the content.
				<li>Take into account the specified 'width'/'height',
					so that the implied minimum is never greater than the specified size.
				<li>Compute to itself (not to ''width/min-content'') on flex items,
					since they are no longer equivalent (due to above changes).
			</ul>
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-19">Issue 19</a>)
			<blockquote>
				<dl>
					<dt>auto
					<dd>
						<del>
							<p>When used as the value of a flex item's min main size property,
							this keyword indicates a minimum of the min-content size,
							to help ensure that the item is large enough to fit its contents.</p>
							<p class='note'>
								It is intended that this will compute to the ''width/min-content'' keyword
								when the specification defining it ([[CSS-SIZING-3]]) is sufficiently mature.
							</p>
						</del>
						<ins>
							<p>On a <a>flex item</a> whose 'overflow' is not ''overflow/visible'',
							this keyword specifies as the minimum size the smaller of:
							<ul>
								<li>the <a>min-content size</a>, or
								<li>the computed 'width'/'height', if that value is <a>definite</a>.
							</ul>
						</ins>
				</dl>
			</blockquote>
		<li id="change-2012-percent-margins">
			Specified that percentage margins/paddings on flex items
			are resolved against their respective dimensions,
			not the inline dimension of the containing block like blocks do.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-16">Issue 16</a>)
			<blockquote>
				<ins>
					<p>Percentage margins and paddings on <a>flex items</a>
					are always resolved against their respective dimensions;
					unlike blocks, they do not always resolve against
					the inline dimension of their containing block.</p>
				</ins>
			</blockquote>
		<li id="change-2012-stretch-definite">
			Pass definiteness of a single-line flex container's size through to any stretched items.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-3">Issue 3</a>)
			<blockquote>
				<ins>
					<p>
						As a special case for handling stretched <a>flex items</a>,
						if a <a>single-line</a> <a>flex container</a> has a definite <a>cross size</a>,
						the outer <a>cross size</a> of any <a>flex items</a> with ''align-self: stretch''
						is the flex container's inner <a>cross size</a>
						(clamped to the <a>flex item</a>’s min and max <a>cross size</a>)
						and is considered <a>definite</a>.</p>
				</ins>
			</blockquote>
		<li id="change-2012-stretch-auto">
			Allow percentages inside a stretched auto-height flex item to resolve by requiring a relayout pass.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-3">Issue 3</a>)
			<blockquote>
				<ins>
					<p>If the flex item has ''align-self: stretch'', redo layout for its contents,
					treating this used size as its definite <a>cross size</a>
					so that percentage-sized children can be resolved.

					<p class="note">Note that this step does not affect the main size of the flex item,
					even if it has an intrinsic aspect ratio.</p>
				</ins>
			</blockquote>
		<li id="change-2012-intrinsic-ratio">
			Allow intrinsic aspect ratios to inform the <a href="#algo-main-item">main-size calculation.</a>
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-8">Issue 8</a>)
			<blockquote>
				<ins>
					<p>If the flex item has ...
					<ul>
						<li>an intrinsic aspect ratio,
						<li>a <a>flex basis</a> of <a value for=width>auto</a>, and
						<li>a definite <a>cross size</a>
					</ul>
					<p>then the <a>flex base size</a> is calculated from its inner <a>cross size</a>
					and the <a>flex item</a>&rsquo;s intrinsic aspect ratio.</p>
				</ins>
			</blockquote>
		<li id="change-2012-main-depend-cross">
			Define <a>hypothetical main size</a> when the <a>main size</a> depends on the <a>cross size</a>.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-23">Issue 23</a>)
			<blockquote>
				<p><ins>If a <a>cross size</a> is needed to determine the <a>main size</a>
					(e.g. when the <a>flex item</a>’s <a>main size</a> is in its block axis)
					and the <a>flex item</a>’s <a>cross size</a> is ''auto'' and not <a>definite</a>,
					in this calculation use ''height/fit-content'' as the <a>flex item</a>’s <a>cross size</a>.</ins>
			</blockquote>
		<li id="change-2012-intrinsic-sizes">
			Defined the <a href="#intrinsic-sizes">intrinsic sizes of flex containers.</a>
			<blockquote>
				<p><strong>Determine the main size of the flex container</strong>
				using its main size property.
				<del>In this calculation, the min content main size of the flex container
				is the maximum of the flex container's items' min-content size contributions,
				and the max content main size of the flex container
				is the sum of the flex container's items' max-content size contributions.
				The min-content/max-content main size contribution of an item is
				its outer hypothetical main size
				when sized under a min-content/max-content constraint (respectively).</del>
				For this computation, ‘auto’ margins on flex items are treated as ‘0’.
			</blockquote>
			<blockquote>
				<ins>
				<!--
					<h3 id="intrinsic-sizes">
					Intrinsic Sizes</h3>
				-->
					<p>
						The <a>max-content</a> <a>main size</a> of a <a>flex container</a>
						is the sum of the flex container's items' <a>max-content contributions</a> in the <a>main axis</a>.
						The <a>min-content</a> <a>main size</a> of a <a>single-line</a> flex container
						is the sum of the flex container's items' <a>min-content contributions</a> in the <a>main axis</a>;
						for a <a>multi-line</a> container,
						it is the largest of those contributions.

					<p>
						The <a>min-content</a> <a>cross size</a> and <a>max-content</a> <a>cross size</a> of a flex container
						are the <a>cross size</a> of the flex container
						after performing layout into the given available <a>main-axis</a> space
						and infinite available <a>cross-axis</a> space.

					<p>
						The main-size <a lt="min-content contribution">min-content</a>/<a>max-content contribution</a> of a <a>flex item</a>
						is its outer <a>hypothetical main size</a>
						when sized under a <a lt="min-content constraint">min-content</a>/<a>max-content constraint</a> (respectively).

					<p>
						See [[!CSS-SIZING-3]] for a definition of the terms in this section.</p>
				</ins>
			</blockquote>
		<li id="change-2012-flex-line-bug">
			Correct an omission in the flex-line size determination,
			so a <a>single-line</a> flexbox will size to its contents
			if it doesn't have a definite size.
			<blockquote>
				<p>
					If the flex container has only one <a>flex line</a>
					(even if it's a <a>multi-line</a> <a>flex container</a>)
					<ins>and has a <a>definite</a> <a>cross size</a></ins>,
					the <a>cross size</a> of the <a>flex line</a>
					is the <a>flex container</a>'s inner <a>cross size</a>.
			</blockquote>
		<li id="change-2012-flex-line-floor">
			Flex lines have their size floored at 0.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-2">Issue 2</a>)
			<blockquote>
				<p>The used <a>cross size</a> of the <a>flex line</a> is the <del>larger</del> <ins>largest</ins>
				of the numbers found in the previous two steps<ins> and zero</ins>.
			</blockquote>
		<li id="change-2012-atomic-painting">
			Flex items paint like inline blocks rather than blocks.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-18">Issue 18</a>)
			<blockquote>
				<p>
					<a>Flex items</a> paint exactly the same as <del>block-level elements in the normal flow</del> <ins>inline blocks [[!CSS2]]</ins>.
			</blockquote>
		<li id="change-2012-flex-basis-zero">
			An omitted 'flex-basis' component of the 'flex' shorthand
			now resolves to ''0%'' instead of ''0px''.
			Because percentages resolved against indefinite sizes behave as ''auto'',
			this gives better behavior in shrink-wrapped flex containers.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-20">Issue 20</a>)
			<blockquote>
				<p>When omitted from the 'flex' shorthand, its specified value is <ins>''0%''</ins> <del>the length zero</del>.
			</blockquote>
			<blockquote>
				<dl>
					<dt>''flex: &lt;positive-number>''
					<dd>Equivalent to ''flex: &lt;positive-number> 1 <del>0px</del><ins>0%</ins>''.
				</dl>
			</blockquote>
			Note: This change was <a href="#change-2015-flex-basis-zero">reverted</a>.
		<li id="change-2012-unresolvable-basis">
			Defined that an unresolvable percentage <a>flex base size</a> is treated as <a value for=width>auto</a>.
			<blockquote>
				<p>percentage values of 'flex-basis' are resolved against
				the flex item's containing block, i.e. its flex container,
				and if that containing block's size is <a>indefinite</a>,
				the result is <del>undefined</del> <ins>the same as a <a>main size</a> of <a value for=width>auto</a></ins>.
			</blockquote>
		<li id="change-2012-static-pos">
			Simplified the static position of abspos children of <a>flex containers</a> to be consistent with Grid Layout.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-6">Issue 6</a>)
			<blockquote>
				An absolutely-positioned child of a <a>flex container</a> does not participate in flex layout
				beyond the reordering step.

				<del>
					<p>
						However, if both 'left' and 'right' or both 'top' and 'bottom' are ''auto'',
						then the used value of those properties
						are computed from its static position, as follows:

					<p>
						If both 'left' and 'right' are ''auto'',
						the <a>flex item</a> must be positioned so that
						its <a>main-start</a> or <a>cross-start</a> edge
						(whichever is in the horizontal axis)
						is aligned with the <a>static position</a>.
						If both 'top' and 'bottom' are ''auto'',
						the <a>flex item</a> must be positioned so that
						its <a>main-start</a> or <a>cross-start</a> edge
						(whichever is in the vertical axis)
						is aligned with the <a>static position</a>.

					<p>
						In the <a>main axis</a>,

					<ol>
						<li>
							If there is a subsequent in-flow <a>flex item</a> on the same <a>flex line</a>,
							the <a>static position</a> is the outer <a>main-start</a> edge of that <a>flex item</a>.

						<li>
							Otherwise, if there is a preceding in-flow <a>flex item</a> on the same <a>flex line</a>,
							the <a>static position</a> is the outer <a>main-end</a> edge of that <a>flex item</a>.

						<li>
							Otherwise, the <a>static position</a> is determined
							by the value of 'justify-content' on the <a>flex container</a>
							as if the <a>static position</a> were represented by a zero-sized flex item.
					</ol>

					<p>
						In the <a>cross axis</a>,

					<ol>
						<li>
							If there is a preceding in-flow <a>flex item</a>,
							the <a>static position</a> is the <a>cross-start</a> edge of the <a>flex line</a>
							that item is in.
						<li>
							Otherwise, the <a>static position</a> is the <a>cross-start</a> edge
							of the first <a>flex line</a>.
					</ol>

					<p class='note'>
						The static position is intended to more-or-less match the position of
						an anonymous 0&times;0 in-flow ''align-self/flex-start''-aligned
						flex item that participates in flex layout,
						the primary difference being that any packing spaces due to
						''justify-content: space-around'' or ''justify-content: space-between''
						are suppressed around the hypothetical item:
						between it and the next item if there is a real item after it,
						else between it and the previous item (if any) if there isn't.</p>
				</del>
				<ins>
					<p>Its static position is calculated by first doing full flex layout
					without the absolutely-positioned children,
					then positioning each absolutely-positioned child
					as if it were the sole <a>flex item</a> in the <a>flex container</a>,
					assuming both the child and the <a>flex container</a>
					were fixed size boxes of their used size.
					<div class='example'>
						For example, by default, the static position of
						an absolutely positioned child aligns it to the main-start/cross-start corner,
						corresponding to the default values of 'justify-content' and 'align-content' on the <a>flex container</a>.
						Setting ''justify-content:center'' on the <a>flex container</a>, however,
						would center it in the main axis.
					</div>
				</ins>
			</blockquote>
		<li id="change-2012-flex-continuity">
			Changed algorithm for <a href="#resolve-flexible-lengths">resolving flexible lengths</a>
			to make behavior continuous as the sum of the flex factors approaches zero.
			(No change for a sum &ge; 1.)
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-30">Issue 30</a>)
			Replaces <a href="https://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#resolve-flexible-lengths">this section</a>
			with <a href="#resolve-flexible-lengths">this one</a>.
	</ul>

<h4 id="changes-2014-clarify">
Clarifications</h4>

	<p>The following significant clarifications were also made:
	<ul>
		<li id="clarify-2012-abspos-items">
			Absolutely positioned children of a flex container are no longer called "flex items" (to avoid terminology confusion). (??)
			<blockquote>
				<table class="definition">
					<tr>
						<th>Name:
						<td>order
					<tr>
						<th>Applies to:
						<td><a>flex items</a> <ins>and absolutely-positioned children of <a>flex containers</a></ins>
				</table>
			</blockquote>
			<blockquote>
				<p>Re-order the flex items <ins>and absolutely positioned flex container children</ins> according to their 'order'.
			</blockquote>
		<li id="clarify-2012-float-display">
			Clarified that 'float' still affects the computed 'display'
			(which may affect box-fixup rules that run prior to flex item determination).
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-7">Issue 7</a>)
			<blockquote>
				<p>'float' and 'clear' have no effect on a <a>flex item</a><ins>,
				and do not take it out-of-flow.
				However, the 'float' property can still affect box generation
				by influencing the 'display' property's computed value.</ins>
			</blockquote>
		<li id="clarify-2012-white-space">
			Clarify what is meant by “white space”. (<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-26">Issue 26</a>)
			<blockquote>
				<p>However, an anonymous flex item that contains only
				<a href="https://www.w3.org/TR/CSS2/text.html#white-space-prop">white space</a>
				<ins>(i.e. characters that can be affected by the 'white-space' property)</ins>
				is not rendered, as if it were ''display:none''.
			</blockquote>
		<li id="clarify-2012-table-anon-boxes">
			Clarified that table anonymous box generation occurs
			in place of computed value conversion for internal table elements.
		<li id="clarify-2012-display-blockification">
			Clarified interaction of flex item determination with <css>display-inside</css> / <css>display-outside</css>
			(the new longhands of 'display' defined in the <a href="https://www.w3.org/TR/css-display/">CSS Display Module Level 3</a>).
			<blockquote>
				<ins><p>If the specified <css>display-outside</css> of an in-flow child of an element that generates a <a>flex container</a>
					is ''inline-level'',
					it computes to ''block-level''.
					(This effectively converts any inline 'display' values to their block equivalents.)</p>
				</ins>
			</blockquote>
			Note: This change was <a href="#change-201409-display-longhands">reverted</a>.
		<li id="clarify-2012-overflow-flex-containers">
			Clarified that 'overflow' applies to flex containers.
		<li id="clarify-2012-first-line-letter">
			Clarified that ''::first-line'' and ''::first-letter'' pseudo-elements
			do not apply to flex containers (because they are not block containers).
		<li id="clarify-2012-stretch-computed-auto">
			Clarify that <a value for=align-self>stretch</a> checks for the <em>computed</em>
			value of the cross-size property being <a value for=width>auto</a>,
			which means that percentage [=cross size|cross sizes=] that behave as <a value for=width>auto</a>
			(because they don't resolve against definite sizes) aren't stretched.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-5">Issue 5</a>)
			<blockquote>
				<dl>
					<dt>stretch
					<dd>
						<p>
							If the <a>cross size property</a> of the <a>flex item</a> <del>is</del> <ins>computes to</ins> <a value for=width>auto</a>,
							its used value is &hellip;
				</dl>
			</blockquote>
			<blockquote>
				<p><strong>Determine the used cross size of each flex item.</strong>
				If a flex item has ''align-self: stretch'',
				its <ins>computed</ins> cross size property is <a value for=width>auto</a>,
				and &hellip;
			</blockquote>
		<li id="clarify-2012-flex-container-sizing">
			Clarify that the rules of the formatting context are used for determining the flex container's main size.
			<blockquote>
				<strong>Determine the main size of the flex container</strong>
				using <ins>the rules of the formatting context in which it participates</ins> <del>its main size property</del>.
			</blockquote>
		<li id="clarify-2012-painting-order">
			Clarified that 'order'-modified document order is used instead of raw document order when painting.
			(This was already stated in the 'order' section, but not in the section explicitly about painting order.)
		<li id="clarify-2012-line-breaking">
			Clarified line-breaking to precisely handle negatively-sized flex items and zero-size items at the end of a line.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-1">Issue 1</a>)
			<blockquote>
				<p>	Otherwise,
					starting from the first uncollected item,
					collect <ins>consecutive items one by one
					until the first time that the <em>next</em> collected item
					would not fit into the flex container's inner main size,
					or until a forced break is encountered.
					If the very first uncollected item wouldn't fit,
					collect just it into the line</ins>
					<del>as many consecutive flex items as will fit
					or until a forced break is encountered
					(but collect at least one)
					into the flex container's inner main size into a flex line</del>.
			</blockquote>
			<blockquote>
				<p class="note">Note that <del>items with zero main size will never start a line
				unless they're  the very first items in the flex container,
				or they're preceded by a forced break.</del>
				The  "collect as many" line will collect <del>them</del> <ins>zero-sized flex items</ins>
				onto the end of the previous line
				even if the last non-zero item exactly "filled up" the line.
			</blockquote>
		<li id="clarify-2012-clamping">
			Clarified that flex container cross sizes are still clamped by the flex container's min/max properties.
			(<a href="https://drafts.csswg.org/css-flexbox-1/issues-cr-2012#issue-24">Issue 24</a>)
			<blockquote>
				<ul>
					<li>
						If the cross size property is a <a>definite</a> size,
						use that,
						<ins>clamped by the min and max cross size properties of the <a>flex container</a></ins>.
					<li>
						Otherwise,
						use the sum of the flex lines' cross sizes,
						<ins>clamped by the min and max cross size properties of the <a>flex container</a></ins>.
				</ul>
			</blockquote>
	</ul>

<h2 class=no-num id=privacy>Privacy Considerations</h2>

No new privacy considerations have been reported on this specification.

<h2 class=no-num id=security>Security Considerations</h2>

No new security considerations have been reported on this specification.

<wpt hidden title="the order property, now in css-display-3">
	animation/order-interpolation.html
	flexbox-anonymous-items-001.html
	flexbox_order-abspos-space-around.html
	flexbox_order-box.html
	flexbox-order-from-lowest.html
	flexbox_order.html
	flexbox_order-noninteger-invalid.html
	flexbox-order-only-flexitems.html
	flexible-order.html
	flex-item-z-ordering-001.html
	flex-item-z-ordering-002.html
	flex-order.html
	getcomputedstyle/flexbox_computedstyle_order.html
	getcomputedstyle/flexbox_computedstyle_order-inherit.html
	getcomputedstyle/flexbox_computedstyle_order-integer.html
	getcomputedstyle/flexbox_computedstyle_order-invalid.html
	getcomputedstyle/flexbox_computedstyle_order-negative.html
	order-001.htm
	order/order-abs-children-painting-order-different-container.html
	order/order-abs-children-painting-order.html
	order/order-with-column-reverse.html
	order/order-with-row-reverse.html
	order-painting.html
	order_value.html
	parsing/order-computed.html
	parsing/order-invalid.html
	parsing/order-valid.html
</wpt>

<wpt hidden title="print stuff">
	break-nested-float-in-flex-item-001-print.html
	break-nested-float-in-flex-item-002-print.html
	flexbox-break-request-horiz-001a.html
	flexbox-break-request-horiz-001b.html
	flexbox-break-request-horiz-002a.html
	flexbox-break-request-horiz-002b.html
	flexbox-break-request-vert-001a.html
	flexbox-break-request-vert-001b.html
	flexbox-break-request-vert-002a.html
	flexbox-break-request-vert-002b.html
	inline-flexbox-vertical-rl-image-flexitem-crash-print.html
</wpt>

<wpt hidden title="non-specific crashers">
	contain-size-layout-abspos-flex-container-crash.html
	frame-flex-item-crash.html
	frameset-crash.html
	grandchild-span-height.html
	min-height-min-content-crash.html
	mixed-containing-blocks-crash.html
	negative-available-size-crash.html
	negative-flex-margins-crash.html
	negative-flex-rounding-crash.html
	negative-item-margins-002-crash.html
	negative-item-margins-crash.html
	orthogonal-flex-item-crash.html
	position-absolute-scrollbar-freeze.html
	position-relative-with-scrollable-with-abspos-crash.html
	relayout-input.html
	remove-out-of-flow-child-crash.html
	zero-content-size-with-scrollbar-crash.html
</wpt>

<wpt hidden title="need quirks mode">
	fixed-table-layout-with-percentage-width-in-flex-item.html
	percentage-size-quirks-002.html
	percentage-size-quirks.html
	quirks-auto-block-size-with-percentage-item.html
</wpt>

<wpt hidden title="css box 3 tests">
	percentage-padding-001.html
	percentage-padding-002.html
	percentage-padding-003.html
	percentage-padding-004.html
	percentage-padding-005.html
</wpt>

<wpt hidden title="unsure/nonspecific">
	remove-wrapped-001.html
	remove-wrapped-002.html
	scrollbars-auto-min-content-sizing.html
	select-element-multiple.html
	shrinking-column-flexbox.html
	table-as-item-large-intrinsic-size.html
	table-with-float-paint.html
</wpt>

<wpt hidden>
	balance/balance-001.html
	balance/balance-002.html
	balance/balance-003.html
	balance/balance-004.html
	balance/balance-005.html
	balance/balance-available-size-001.html
	balance/balance-available-size-002.html
	balance/balance-line-break-crash.html
	balance/balance-line-count-intrinsic-001.html
	balance/balance-line-count-intrinsic-002.html
	balance/balance-line-count-intrinsic-003.html
	balance/balance-line-count-intrinsic-004.html
	balance/balance-line-count-intrinsic-005.html
	balance/balance-line-count-intrinsic-006.html
	balance/balance-line-count-intrinsic-007.html
	balance/balance-min-line-count-001.html
	balance/balance-min-line-count-002.html
	balance/balance-min-line-count-003.html
	balance/balance-min-line-count-004.html
	balance/balance-min-line-count-005.html
	balance/balance-negative-margin.html
	balance/balance-percentage-size-001.html
	balance/balance-percentage-size-002.html
	balance/flex-line-count-computed.html
	balance/flex-line-count-invalid.html
	balance/flex-line-count-valid.html
	balance/flex-wrap-computed.html
	balance/flex-wrap-invalid.html
	balance/flex-wrap-valid.html
</wpt>

