<pre class='metadata'>
Title: CSS Box Sizing Module Level 4
Shortname: css-sizing
Level: 4
Status: ED
Warning: not ready
Work Status: Exploring
Group: csswg
ED: https://drafts.csswg.org/css-sizing
TR: https://www.w3.org/TR/css-sizing/
Editor: Tab Atkins, Google, http://xanthir.com/contact/, w3cid 42199
Editor: Elika J. Etemad / fantasai, Invited Expert, http://fantasai.inkedblade.net/contact, w3cid 35400
Editor: Jen Simmons, Mozilla, http://jensimmons.com/
Previous version: https://www.w3.org/TR/2012/WD-css3-sizing-20120927/
Abstract: This is a delta spec over CSS Sizing Level 3.
Ignored Terms: block-level box
</pre>

<pre class='link-defaults'>
spec:css-display-3; type:dfn; text:box
spec:css-align-3; type:property; text:column-gap
spec:css2; type: property
	text: min-width
	text: min-height
	text: max-width
	text: max-height
</pre>


<!-- Notes on stuff to do... [copy/pasted from etherpad, probably out-of-date, evaluate later]
  Swap definition of preferred size in for max-content.
  Define current max-content as super-max-content.
  Mark an isssue about whether it's a necessary concept;
  I'm unsure, but I think it will show up in orthogonal flow sizing.
-->

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

	ISSUE: This is a diff spec from <a href="https://www.w3.org/TR/css-sizing-3/">CSS Sizing Level 3</a>.
	It is currently an Exploratory Working Draft:
	if you are implementing anything, please use Level 3 as a reference.
	We will merge the Level 3 text into this draft once it reaches CR.

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

	<p>This module extends the 'width', 'height', 'min-width', 'min-height', 'max-width', 'max-height', and 'column-width'
	features defined in [[!CSS2]] chapter 10 and in [[!CSS3COL]]

<h3 id="values">
Values</h3>

	This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]].
	Value types not defined in this specification are defined in CSS Values & Units [[!CSS-VALUES-3]].
	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> keywords as their property value.
	For readability they have not been repeated explicitly.



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

<h2 id="terms">
Terminology</h2>


<h3 id='auto-box-sizes'>
Auto Box Sizes</h3>


<h3 id='contributions'>
Intrinsic Size Contributions</h3>


<h3 id='constraints' dfn export lt="intrinsic size constraint">
Intrinsic Size Constraints</h3>


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

<h2 id="specifying-sizes" oldids='size-keywords'>
Specifying Box Sizes</h2>

<h3 id="sizing-properties">
Sizing Properties</h3>


<h4 id="preferred-size-properties" dfn export lt="preferred size property">
Preferred Size Properties: the 'width' and 'height' properties</h4>


<h4 id="min-size-properties" dfn export lt="min size property">
Minimum Size Properties: the 'min-width' and 'min-height' properties</h4>


<h4 id="max-size-properties" dfn export lt="max size property">
Maximum Size Properties: the 'max-width' and 'max-height' properties</h4>



<h3 id="sizing-values" oldids='width-height-keywords'>
Sizing Values: the <<length-percentage>>, ''width/auto'' | ''max-width/none'', ''width/min-content'', ''width/max-content'', and ''width/fit-content()'' values</h3>


<h4 id="behave-auto">
“Behaving as ''width/auto''”</h4>


<h4 id='the-contain-floats-value'>
Containing or Excluding Floats</h4>


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

<h3 id="box-sizing" caniuse="css3-boxsizing">
Box Edges for Sizing: the 'box-sizing' property</h3>

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

<h3 id='column-sizing'>
New Column Sizing Values: the ''column-width/min-content'', ''column-width/max-content'', and ''column-width/fit-content()'' values</h3>


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

<h2 id="ratios">
Aspect Ratios</h2>

ISSUE: This section is a rough draft proposal.
See discussion in <a href="https://github.com/w3c/csswg-drafts/issues/333">Issue 333</a>
and <a href="https://github.com/w3c/csswg-drafts/issues/1173">Issue 1173</a>.

<h3 id="aspect-ratio">
Intrinsic Aspect Ratios: the 'aspect-ratio' property</h3>

	<pre class="propdef">
	Name: aspect-ratio
	Value: auto | <<ratio>>
	Initial: auto
	Inherited: no
	Applies to: all elements except <a>inline boxes</a> and internal ruby or table boxes
	Computed value: specified keyword or a pair of numbers
	</pre>

	This property sets a <dfn export>preferred aspect ratio</dfn> for the box,
	which will be used in the calculation of ''height/auto'' sizes
	and some other layout functions.
	The box’s <a>automatic sizes</a>
	are then calculated the same as for
	a <a>replaced element</a> with an <a>intrinsic aspect ratio</a>,
	see e.g. <a href="https://www.w3.org/TR/CSS2/visudet.html">CSS2 &sect;&#x202F;10</a>
	and <a href="https://www.w3.org/TR/css-flexbox-1/#algo-main-item">CSS Flexible Box Model Level 1 &sect;&#x202F;9.2</a>.
	The axis in which the <a>preferred size</a> calculation
	depends on this aspect ratio
	is called the <dfn>ratio-dependent axis</dfn>,
	and the resulting size is <a>definite</a>
	if its input sizes are also <a>definite</a>.

	<dl dfn-for="aspect-ratio" dfn-type="value">
		<dt><dfn>auto</dfn>
		<dd>
			<a>Replaced elements</a> with an <a>intrinsic aspect ratio</a>
			use that aspect ratio;
			otherwise the box has no <a>preferred aspect ratio</a>.
			Size calculations involving <a>intrinsic aspect ratio</a>
			work with the <a>content box</a> dimensions always.

		<dt><dfn><<ratio>></dfn>
		<dd>
			The box’s <a>preferred aspect ratio</a> is the specified ratio
			of ''<var>width</var> / <var>height</var>''.
			Size calculations involving <a>preferred aspect ratio</a>
			work with the dimensions of the box specified by 'box-sizing'.

	</dl>

	Note: If a box has both a 'width' and a 'height'
	that are not <a lt="automatic size">automatic</a>
	(or, in the case of a <a>flex item</a>,
	both a ''flex-basis/content'' flex basis and
	a non-<a lt="automatic size">automatic</a> preferred <a>cross size</a>),
	then the <a>preferred aspect ratio</a> has no effect:
	at least one of these sizes must be ''width/auto'' (/''flex-basis/content'')
	for the <a>preferred aspect ratio</a> to have an impact on sizing.

	<div class="example">
		This example sets each item in the grid to render as a square,
		determining the number of items and their widths by the available space.

		<xmp highlight="html">
		  <ul>
		    <li>…
		    <li>…
		    <li>…
		    <li>…
		  </ul>
		</xmp>
		<pre highlight="css">
			ul {
				display: grid;
				grid-template-columns: repeat(auto-fill, minmax(12em, 1fr));
			}
			li {
				aspect-ratio: 1/1;
				overflow: auto;
			}
		</pre>
	</div>

	<div class="example">
		This example uses the <{iframe}> element’s
		<code>width</code> and <code>height</code> attributes
		to set the 'aspect-ratio' property,
		giving the iframe an aspect ratio to use for sizing
		so that it behaves exactly like an image with that aspect ratio.
		<!-- https://twitter.com/ausi/status/1053013616239288320 -->
		<pre highlight="html">
			&lt;iframe
			  src="https://www.youtube.com/embed/0Gr1XSyxZy0"
			  width=560
			  height=315>
		</pre>
		<pre highlight="css">
			@supports (aspect-ratio: attr(width) / 1) {
			  iframe {
			    aspect-ratio: attr(width) / attr(height);
			    width: 100%;
			    height: auto;
			  }
			}
		</pre>
		ISSUE: Can we just slip this 'aspect-ratio' rule
		into the UA default style sheet for images,
		so that they have an aspect ratio while they load?
		This would avoid the need for extra reflows after loading.
	</div>

	On non-replaced elements with an ''width/auto'' <a>inline size</a>
	(or any replaced element whose intrinsic <a>block size</a>
	depends on its <a>inline size</a>),
	the intrinsic <a>block sizes</a> of the box
	are assumed to be zero
	when applying 'min-block-size' to the aspect ratio calculations,
	and assumed to be infinity
	when applying 'max-block-size' to the aspect ratio calculations.
	These limits take effect as usual for non-replaced elements
	once the <a>inline size</a> is resolved.

	<div class="example">
		For example, given a (<a>horizontal writing mode</a>) element with
		<pre>
		  width: auto;
		  min-height: min-content;
		  aspect-ratio: 1/1;
		</pre>

		using the aspect ratio to resolve the width
		would require knowing the min-content height of the element.

		Since for a non-replaced element,
		this value is not known until the width is resolved,
		we assume the 'min-height' value is zero
		while resolving the width.

		Then, once the width is known, we resolve the height,
		taking into account the ''height/min-content'' minimum.
	</div>

<h4 id="aspect-ratio-minimum">
Automatic Content-based Minimum Sizes</h4>

	In order to avoid unintentional overflow,
	the <a>automatic minimum size</a> in the <a>ratio-dependent axis</a>
	of a box with a <a>preferred aspect ratio</a>
	that is neither a <a>replaced element</a> nor a <a>scroll container</a>
	is the minimum of
	its <a>min-content size</a> and its <a>maximum size</a>.

	<div class="example">
		In the following example,
		the box is as wide as the container (as usual),
		and its height is as tall as needed to contain its content
		but at least as tall as it is wide.

		<pre>
		  div {
		    aspect-ratio: 1/1;
		    /* 'width' and 'height' both default to 'auto' */
		  }
		</pre>

		<pre class="figure">
		+----------+  +----------+  +----------+
		| ~~~~~~~~ |  | ~~~~~~~~ |  | ~~~~~~~~ |
		| ~~~~~~~~ |  | ~~~~~~~~ |  | ~~~~~~~~ |
		| ~~~~~~~  |  | ~~~~~~~~ |  | ~~~~~~~~ |
		|          |  | ~~~      |  | ~~~~~~~~ |
		+----------+  +----------+  | ~~~~~~~~ |
		                            | ~~~~~~   |
		                            +----------+
		</pre>

		When ''overflow: auto'' is specified, however,
		even the box with excess content maintains the 1:1 aspect ratio.

		<pre>
		  div {
		    overflow: auto;
		    aspect-ratio: 1/1;
		  }
		</pre>

		<pre class="figure">
		+----------+  +----------+  +----------+
		| ~~~~~~~~ |  | ~~~~~~~~ |  | ~~~~~~~~^|
		| ~~~~~~~~ |  | ~~~~~~~~ |  | ~~~~~~~~ |
		| ~~~~~~~  |  | ~~~~~~~~ |  | ~~~~~~~~ |
		|          |  | ~~~      |  | ~~~~~~~~v|
		+----------+  +----------+  +----------+
		</pre>

		Overriding the 'min-height' property also maintains the 1:1 aspect ratio,
		but will result in content overflowing the box
		if it is not otherwise handled.

		<pre>
		  div {
		    aspect-ratio: 1/1;
		    min-height: 0;
		  }
		</pre>

		<pre class="figure">
		+----------+  +----------+  +----------+
		| ~~~~~~~~ |  | ~~~~~~~~ |  | ~~~~~~~~ |
		| ~~~~~~~~ |  | ~~~~~~~~ |  | ~~~~~~~~ |
		| ~~~~~~~  |  | ~~~~~~~~ |  | ~~~~~~~~ |
		|          |  | ~~~      |  | ~~~~~~~~ |
		+----------+  +----------+  +-~~~~~~~~-+
		&nbsp;                             ~~~~~~   &nbsp;
		</pre>
	</div>



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

<h2 id='intrinsic'>
Intrinsic Size Determination</h2>

ISSUE: <strong>Need to Sync This Section With Level 3 It is Super Out Of Date</strong>

	<dfn export lt="intrinsic size">Intrinsic sizing</dfn> determines sizes based on the contents of a box,
	without regard for the context in which it is placed.

	Precisely how to calculate the [=intrinsic size=] of a box depends on its layout mode;
	the following subsections define intrinsic sizing for several types of layouts.
	Individual layout modes,
	such as Flexbox or Grid,
	can define their own intrinsic sizing rules.

	If a box has an [=explicit intrinsic inner size=] in an axis,
	then that is all of its [=intrinsic sizes=] in that axis.
	If the other axis does not have an [=explicit intrinsic inner size=],
	then its intrinsic sizes are determined normally,
	without regard for the [=explicit intrinsic inner size=] in the first axis.


<h3 id='replaced-intrinsic'>
Intrinsic Sizes of Replaced Elements</h3>

	<p>
		For replaced elements,
		the <a>min-content size</a> and <a>max-content size</a> are equivalent
		and correspond to the appropriate dimension of the concrete object size returned by
		the <a href="https://www.w3.org/TR/css3-images/#default-sizing">default sizing algorithm</a> [[!CSS3-IMAGES]]
		of the element,
		calculated with an unconstrained specified size.

	The <a>min-content contribution</a> and <a>max-content contribution</a> in each axis
	is the element's specified outer size in that axis, if definite;
	otherwise, they are the <a>min-content size</a>, as specified above,
	plus the element's margin/border/padding in that axis,
	clamped by the element's min and max size properties in that axis.

<h3 id='inline-intrinsic'>
Intrinsic Sizes of Non-Replaced Inlines</h3>

	<p>
		The <a>min-content inline size</a> of an inline box
		is the length of the largest unbreakable sequence of inline content.
		The <a>min-content inline-size contribution</a> of an inline box
		is its <a>min-content inline size</a>,
		plus any <a>inline-axis</a> margin, border, and padding
		adjacent to that sequence.

	<p>
		The <a>max-content inline size</a> of an inline box
		is the length of the largest sequence of inline content
		on a single line
		when only forced line breaks are taken.
		The <a>max-content inline-size contribution</a> of an inline box
		is its <a>max-content inline size</a>,
		plus any <a>inline-axis</a> margin, border, and padding
		adjacent to that sequence.

	<p>
		The <a>min-content block size</a>, <a>max-content block size</a>, <a>min-content block-size contribution</a>, and <a>max-content block-size contribution</a> of an inline box
		are the distance from the head edge of the first line box
		to the foot edge of the last line box
		on which the inline appears.

<h3 id='block-intrinsic'>
Intrinsic Sizes of Non-Replaced Blocks</h3>

	<p>
		The <a>min-content inline size</a> of a <a>block container box</a>
		is the largest <a>min-content inline-size contribution</a>
		of its in-flow or floated children.

	<p>
		The <a>max-content inline size</a> of a <a>block container box</a>
		is the inline-size of the box after layout,
		if all children are sized under a <a>max-content constraint</a>.
	<p>
		If the computed inline-size of a <a>block-level box</a>
		is ''width/min-content'', ''width/max-content'', or a <a>definite size</a>,
		its <a>min-content inline-size contribution</a>
		is that size
		plus any <a>inline-axis</a> margin, border, and padding.
		Otherwise, if the computed inline-size of the block is ''width/fit-content'', ''width/auto'', or ''width/stretch'',
		its <a>min-content inline-size contribution</a>
		is its <a>min-content inline size</a>
		plus any <a>inline-axis</a> margin, border, and padding.

	<p>
		If the computed inline-size of a <a>block-level box</a>
		is ''width/min-content'', ''width/max-content'', or a <a>definite size</a>,
		its <a>max-content inline-size contribution</a>
		is that size
		plus any <a>inline-axis</a> margin, border, and padding.
		Otherwise, if the computed inline-size of the block is ''width/fit-content'', ''width/auto'', or ''width/stretch'',
		its <a>max-content inline-size contribution</a>
		is its <a>max-content inline size</a>
		plus any <a>inline-axis</a> margin, border, and padding.

	<p>
		The <a>min-content block size</a> and <a>max-content block size</a> of a <a>block container box</a>
		is the content block-size as defined
		(for horizontal writing modes)
		in <a href="https://www.w3.org/TR/CSS2/visudet.html#normal-block">CSS2.1§10.6.3</a>
		and <a href="https://www.w3.org/TR/CSS2/tables.html#height-layout">CSS2.1§17.5.3</a>
		for elements with ''height: auto'',
		and analogously for vertical writing modes.

	<p>
		The <a>min-content block-size contribution</a> and <a>max-content block-size contribution</a> of a <a>block-level box</a>
		is the block-size of the block after layout,
		plus any <a>block-axis</a> margin, border, and padding.

	Issue: Need to handle floats.
	See <a href="https://lists.w3.org/Archives/Public/www-style/2014Oct/0061.html">Greg's issue</a>
	and <a href="https://lists.w3.org/Archives/Public/www-style/2014Nov/0085.html">dbaron's response</a>.

<h3 id='table-intrinsic'>
Intrinsic Sizes in Table Layout</h3>

	<p class='issue'>
		¯\_(ツ)_/¯



<h3 id="multicol-intrinsic">
Intrinsic Sizes in Multi-column Layout</h3>


<h4 id="multicol-min-content">
Min-content Sizes in Multi-column Layout</h3>

	<p>
		The <a>min-content inline size</a> of a multi-column container
		with a computed 'column-width' not ''column-width/auto''
		is the smaller of
		its 'column-width'
		and the largest <a>min-content inline-size contribution</a> of its contents.

	<p>
		The <a>min-content inline size</a> of a multi-column container
		with a computed 'column-width' of ''column-width/auto''
		is the largest <a>min-content inline-size contribution</a> of its contents
		multiplied by its 'column-count'
		(treating ''column-count/auto'' as ''1''),
		plus its 'column-gap' multiplied by 'column-count' minus 1.

<h4 id="multicol-max-content">
Max-content Sizes in Unconstrained-height Multi-column Layout</h3>

	<p>
		The <a>max-content inline size</a> of a multi-column container
		with unrestrained column heights
		and a computed 'column-count' not ''column-count/auto''
		is its 'column-count'
		multiplied by the larger of
		its 'column-width' (treating ''column-width/auto'' as zero)
		and the largest <a>min-content inline-size contribution</a> of its contents,
		plus its 'column-gap' multiplied by 'column-count' minus 1.

	<p class="note">
		Note that the contents of the multi-column container
		can still grow to be wider and shorter
		if the resulting column width is still smaller
		than the largest <a>max-content inline-size contribution</a> of its contents.

	<p>
		The <a>max-content inline size</a> of a multi-column container
		with unrestrained column heights
		and a computed 'column-count' of ''column-count/auto''
		is its 'column-width'
		multiplied by the number of columns obtained by taking all allowed column breaks [[CSS3-BREAK]],
		plus its 'column-gap' multiplied by that same number of columns minus 1.

	<!--
	The above was decided based on dholbert's example in http://lists.w3.org/Archives/Public/www-style/2012Oct/0017.html .
	These definitions make multicols work well in flexbox,
	both in ''stretch'' and non-''stretch'' cases,
	without wasted space or needless overflow.
	-->

<h4 id="multicol-max-content-restrained">
Max-content Sizes in Constrained-height Multi-column Layout</h3>

	<p>
		The <a>max-content inline size</a> of a multi-column container
		with restrained-height columns (i.e. a specified 'height' or 'max-height', or whichever properties map to the <a>block size</a> of the element)
		is the <a>inline size</a> that would exactly include all of its columns.
		It may be approximated by:

	<ul>
		<li>
			Laying out the element with column-spanning elements given ''display: none'',
			and taking a inline-size that includes all the columns.

		<li>
			Laying out all of the column-spanning elements into that resulting inline-size,
			and taking the resulting block-size.

		<li>
			Subtracting that resulting block-size from the specified restraint,
			laying out the element without column-spanning elements again into this adjusted block-size,
			and taking the inline-size of all its columns as its <a>max-content inline size</a>.
	</ul>

	<p>
		or by some more accurate method.

	<p class='note'>
		This approximation can result in some slack,
		but avoids overflow in the most common cases,
		where the balanced height of the columns above spanning elements are approximately equal.

	<p class='note'>
		In the common case of no column-spanning elements,
		this approximation collapses to simply doing a layout,
		and measuring the resulting columns.


<h3 id='intrinsic-size-override'>
Overriding Intrinsic Sizes: the 'intrinsic-*' properties</h3>

	<pre class="propdef">
	Name: intrinsic-block-size, intrinsic-inline-size, intrinsic-height, intrinsic-width
	Value: legacy | auto | <<length>>
	Initial: legacy
	Inherited: no
	Applies to: all elements except [=non-replaced=] [=inlines=]
	Computed value: as specified, with <<length-percentage>> values computed
	Percentages: n/a
	Animation type: by computed value type
	</pre>

	The 'intrinsic-*' properties determine
	whether the [=intrinsic sizes=] of a box
	are calculated from sizes derived from its content
	(as defined by the rest of this chapter),
	or from a specified <dfn export>explicit intrinsic inner size</dfn>.
	Values are defined as follows:

	<dl dfn-type=value dfn-for="intrinsic-block-size, intrinsic-inline-size, intrinsic-height, intrinsic-width, intrinsic-size">
		: <dfn>legacy</dfn>
		::
			Does not specify an [=explicit intrinsic inner size=] of the box
			in the relevant axis.
			(Intrinsic sizes are thus determined in various ways
			based on examining the content of the box as usual.
			See [[#intrinsic]], for example.)


		: <dfn>auto</dfn>
		::
			If 'overflow' is not ''visible'' in the relevant axis,
			specifies a zero [=explicit intrinsic inner size=]
			in that axis.
			Otherwise same as ''legacy''.

		: <dfn><<length>></dfn>
		::
			Specifies an [=explicit intrinsic inner size=]
			in the relevant axis.
	</dl>

	Note: The value of 'intrinsic-*' in one axis has no affect on the other axis.

	<pre class="propdef shorthand">
	Name: intrinsic-size
	Value: <<'intrinsic-width'>> <<'intrinsic-height'>>?
	</pre>

	The 'intrinsic-size' property is a [=shorthand=]
	for setting all the 'intrinsic-*' properties in one declaration.

	The first value sets 'intrinsic-width',
	and the second value sets 'intrinsic-height'.
	If the second value is omitted,
	it defaults to the first.

	Issue: When we figure out how to make other physical x/y shorthands,
	like 'background-size',
	work with logical sizes,
	we'll apply the same logic here.


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

<h2 id="intrinsic-contribution">
Intrinsic Size Contributions</h2>

	A box’s <a>min-content contribution</a>/<a>max-content contribution</a> in each axis
	is the size of the content box
	of a hypothetical ''width/auto''-sized float
	that contains only that box,
	if that hypothetical float's containing block is zero-sized/infinitely-sized.

	Note: This specification does not define precisely how to determine these sizes.
	Please refer to [[CSS2]],
	the relevant CSS specification for that display type,
	the <a href="#percentage-sizing">rules for handling percentages</a> (below),
	and/or existing implementations
	for further details.



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

<h2 id='extrinsic'>
Extrinsic Size Determination</h2>

	…

<h3 id="stretch-fit-sizing">
Stretch-fit Sizing</h3>

	…

<h3 id="contain-fit-sizing">
Contain-fit Sizing: stretching while maintaining an aspect ratio</h3>

	Contain-fit sizing essentially applies stretch-fit sizing,
	but reduces the size of the box in one axis
	to maintain the box’s intrinsic aspect ratio,
	similar to the ''object-fit/contain'' keyword of the 'object-fit' and 'background-size' properties.

	First, a target rectangle is determined:

	<ol>
		<li>
			The initial target rectangle is the size of the box’s containing block,
			with any indefinite size assumed as infinity.
			If both dimensions are indefinite,
			the initial target rectangle is set
			to match the outer edges of the box were it <a>stretch-fit sized</a>.

		<li>
			Next, if the box has a non-''max-width/none'' 'max-width' or 'max-height',
			the target rectangle is clamped in the affected dimension
			to less than or equal to the “maximum size” of the box’s margin box,
			i.e. the size its margin box would be
			if the box was sized at its max-width/height.
			(Note that, consistent with normal <a href="http://www.w3.org/TR/CSS2/visuren.html">box-sizing rules</a>,
			this “maximum size” is floored by the effects of the box’s 'min-width'/'min-height'.)

		<li>
			Last, the target rectangle is reduced in one dimension
			by the minimum necessary for it to match the box's intrinsic aspect ratio.
	</ol>

	The contain-fit size in each dimension is
	the size that would result from stretch-fitting into the target rectangle.

	Issue: Copy whatever stretch-fit ends up doing wrt margin collapsing.

	Issue: If there is a minimum size in one dimension
	that would cause overflow of the target rectangle if the aspect ratio were honored,
	do we honor the aspect ratio or skew the image?
	If the former, we need a step similar to #2 that applies the relevant minimums.

<h3 id="percentage-sizing">
Percentage Sizing</h3>

	…

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

	<p>
		Changes since the <a href="https://www.w3.org/TR/2012/WD-css3-sizing-20120927/">September 2012 Working Draft</a> include:

	<ul>
		<li>Changed <code>fill</code> keyword to <code>stretch-fit</code>.
		<li>Hooked up intrinsic sizes of replaced elements to the <a>default sizing algorithm</a> in [[!CSS3-IMAGES]].
		<li>Specified that <a>extrinsic sizing</a> treates ''margin/auto'' margins as zero.
		<li>Clarified definition of <a>available space</a>.
		<li>Specified that percentages resolved against an intrinsic size of the parent computes falls back to auto sizing.
		<li>Fixed bad wording wrt containing blocks in <a>stretch-fit inline size</a> definition,
		    and specified that it is calculated <em>after</em> margin collapsing.
		<li>Specified that an absolutely-positioned box's containing block is always considered definite.
		<li>Improved section on intrinsic sizing of multi-column containers.
		<li>Cleaned up some terminology (“min-size” to “min-content size”, “measure” to “inline-size, “extent” to “block-size”).
	</ul>

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

	<p>Special thanks go to Aaron Gustafson, L. David Baron
	for their contributions to this module.

<h2 class=no-num id=priv-sec>
Privacy and Security Considerations</h2>

This specification introduces no new privacy or security considerations.
