<pre class='metadata'>
Title: CSS Box Sizing Module Level 4
Shortname: css-sizing
Level: 4
Status: ED
Work Status: Revising
Group: csswg
ED: https://drafts.csswg.org/css-sizing-4/
TR: https://www.w3.org/TR/css-sizing-4/
Issue Tracking: CSSWG GitHub https://github.com/w3c/csswg-drafts/issues
Previous Version: https://www.w3.org/TR/2021/WD-css-sizing-4-20210520/
Editor: Tab Atkins, Google, http://xanthir.com/contact/, w3cid 42199
Editor: Elika J. Etemad / fantasai, Apple, http://fantasai.inkedblade.net/contact, w3cid 35400
Editor: Jen Simmons, Apple, http://jensimmons.com/, w3cid 52801
Abstract: This module extends the CSS sizing properties with keywords that represent content-based "intrinsic" sizes and context-based "extrinsic" sizes, allowing CSS to more easily describe boxes that fit their content or fit into a particular layout context. This is a delta spec over CSS Sizing Level 3.
Ignored Terms: block-level box
Test Suite: https://wpt.fyi/results/css/css-sizing
WPT Path Prefix: css/css-sizing/
WPT Display: closed
</pre>

<pre class='link-defaults'>
spec:css-align-3;
	type:property; text:column-gap
	type:value; text:stretch
spec:css-borders-4; type:property; text:border
spec:css-display-3; type:dfn; text:box
spec:css-logical-1; type:property; text:block-size
spec:css-values-5; type:function; text:calc-size()
spec:css2; type:property
	text:min-width
	text:min-height
	text:max-width
	text:max-height
spec:html; type:element;
	text:meta
	text:head
	text:body
spec:css2; type:dfn; text:document language
</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 issue 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 over <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.

	<wpt title="General sizing tests">
		dynamic-available-size-iframe.html
		dynamic-change-inline-size-001.html
		dynamic-change-inline-size-002.html
		dynamic-change-inline-size-003.html
		dynamic-change-inline-size-004.html
		frameset-intrinsic-crash.html
		inheritance-001.html
		inheritance-002.html
		min-width-max-width-precedence.html
		min-width-max-width-precedence.html
		replaced-max-size-saturation.html
		responsive-iframe/responsive-iframe-no-match-element.html
		textarea-large-padding-crash.html
	</wpt>

<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">
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.

<!-- Big Text: terms

█████▌ █████▌ ████▌  █     █  ███▌ 
  █▌   █▌     █▌  █▌ ██   ██ █▌  █▌
  █▌   █▌     █▌  █▌ █▌█ █▐█ █▌    
  █▌   ████   ████▌  █▌ █ ▐█  ███▌ 
  █▌   █▌     █▌▐█   █▌   ▐█     █▌
  █▌   █▌     █▌ ▐█  █▌   ▐█ █▌  █▌
  █▌   █████▌ █▌  █▌ █▌   ▐█  ███▌ 
-->

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

Issue: [[css-sizing-3#terms]]

<!-- merge this with the final sizing-3 definition
<dt><dfn export>preferred aspect ratio</dfn>
<dd>
    A [=box=] or [=replaced element=]’s preferred ratio of width to height.
    This can be explicitly specified via the 'aspect-ratio' property,
    or, for replaced elements, it can be an [=intrinsic aspect ratio=]
    derived from the content.
    The [=preferred aspect ratio=] of a box can be associated
    with either its [=content box=] or [=border box=].
    Not all boxes or replaced elements have a [=preferred aspect ratio=]
    (and in fact, non-replaced elements typically do not).
-->

<!-- Big Text: propdefs

████▌  ████▌   ███▌  ████▌  ████▌  █████▌ █████▌  ███▌ 
█▌  █▌ █▌  █▌ █▌  █▌ █▌  █▌ █▌  █▌ █▌     █▌     █▌  █▌
█▌  █▌ █▌  █▌ █▌  █▌ █▌  █▌ █▌  █▌ █▌     █▌     █▌
████▌  ████▌  █▌  █▌ ████▌  █▌  █▌ ████   ████    ███▌ 
█▌     █▌▐█   █▌  █▌ █▌     █▌  █▌ █▌     █▌         █▌
█▌     █▌ ▐█  █▌  █▌ █▌     █▌  █▌ █▌     █▌     █▌  █▌
█▌     █▌  █▌  ███▌  █▌     ████▌  █████▌ █▌      ███▌ 
-->

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

ISSUE: [[css-sizing-3#specifying-sizes]]

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

ISSUE(820): Add shorthands.

<h3 id="sizing-values" oldids='width-height-keywords'>
New Sizing Values: the ''stretch'', ''fit-content'', and ''contain'' keywords</h3>

	<pre class="propdef partial">
	Name: width, height, min-width, min-height, max-width, max-height
	New Values: stretch | fit-content | contain
	</pre>

	<dl dfn-type=value dfn-for="width, height, inline-size, block-size, min-width, min-height, min-inline-size, min-block-size, max-width, max-height, max-inline-size, max-block-size">
		<dt><dfn>stretch</dfn>
		<dd>
			Applies [=stretch-fit sizing=],
			attempting to match the size of the box’s [=margin box=] to the size of its [=containing block=].
			See [[#stretch-fit-sizing]].

			<wpt>
				stretch/block-height-001.html
				stretch/flex-line-001.html
				stretch/flex-line-002.html
				stretch/flex-line-003.html
				stretch/flex-line-004.html
				stretch/flex-line-005.html
				stretch/min-width-1.html
				stretch/parsing.html
				stretch/positioned-non-replaced-1.html
				stretch/positioned-replaced-1.html
				stretch/positioned-replaced-2.html
				stretch/positioned-replaced-3.html
				stretch/stretch-block-size-001.html
				stretch/stretch-block-size-002.html
				stretch/stretch-block-size-003.html
				stretch/stretch-inline-size-001.html
				stretch/stretch-inline-size-002.html
				stretch/stretch-inline-size-003.html
				stretch/stretch-max-block-size-001.html
				stretch/stretch-max-inline-size-001.html
				stretch/stretch-min-block-size-001.html
				stretch/stretch-min-inline-size-001.html
				stretch/stretch-quirk-001.html
			</wpt>

		<dt><dfn>fit-content</dfn>
		<dd>
			Essentially ''fit-content(stretch)''
			i.e. min(''width/max-content'', max(''width/min-content'', ''width/stretch'')).

			<wpt>
				fit-content-block-size-abspos.html
				fit-content-block-size-fixedpos.html
				fit-content-contribution-001.html
				fit-content-min-inline-size.html
				fit-content-percentage-padding.html
				float-clearance-with-margin-collapse-and-fit-content-and-padding-percentage-001.html
				float-clearance-with-margin-collapse-and-fit-content-and-padding-percentage-002.html
				float-clearance-with-margin-collapse-and-fit-content-and-padding-percentage-003.html
				float-clearance-with-margin-collapse-and-fit-content-and-padding-percentage-004.html
			</wpt>

		<dt><dfn>contain</dfn>
		<dd>
			If the box has a [=preferred aspect ratio=],
			applies [=contain-fit sizing=],
			attempting to fit into the box’s constraints
			while maintaining its [=preferred aspect ratio=] insofar as possible.
			See [[#contain-fit-sizing]].

			If the box has no [=preferred aspect ratio=],
			applies [=stretch-fit sizing=].
	</dl>

	Note: These new values add to the set of values
	that the definition of <<calc-size()>>
	refers to as "allowed in the context".

<!-- Big Text: aspect-r

 ███▌   ███▌  ████▌  █████▌  ███▌  █████▌       ████▌ 
▐█ ▐█  █▌  █▌ █▌  █▌ █▌     █▌  █▌   █▌         █▌  █▌
█▌  █▌ █▌     █▌  █▌ █▌     █▌       █▌         █▌  █▌
█▌  █▌  ███▌  ████▌  ████   █▌       █▌   ████▌ ████▌
█████▌     █▌ █▌     █▌     █▌       █▌         █▌▐█  
█▌  █▌ █▌  █▌ █▌     █▌     █▌  █▌   █▌         █▌ ▐█ 
█▌  █▌  ███▌  █▌     █████▌  ███▌    █▌         █▌  █▌
-->

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

	Images often have a [=natural aspect ratio=],
	which the CSS layout algorithms attempt to preserve
	as they resize the element.

	The 'aspect-ratio' property allows specifying this behavior
	for non-replaced elements,
	and for altering the effective aspect ratio of replaced elements.

	ISSUE: We are still working through the details of this section.
	If there is any behavior specified here
	that would cause [=replaced elements=] with a [=preferred aspect ratio=]
	to behave differently than they would
	under the requirements of the
	<a href="https://www.w3.org/TR/CSS2/visudet.html">CSS2</a>,
	<a href="https://www.w3.org/TR/css-flexbox-1/">Flex Layout</a>,
	and <a href="https://www.w3.org/TR/css-grid-1/">Grid Layout</a>
	specs combined (without this specification in effect),
	<strong>this is an error and should be <a href="https://github.com/w3c/csswg-drafts/issues">reported</a> to the CSSWG</strong>.

<h3 id="aspect-ratio">
Preferred 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
	Animation type: by computed value
	</pre>

	<wpt>
		animation/aspect-ratio-interpolation.html
		aspect-ratio/abspos-001.html
		aspect-ratio/abspos-002.html
		aspect-ratio/abspos-003.html
		aspect-ratio/abspos-004.html
		aspect-ratio/abspos-005.html
		aspect-ratio/abspos-006.html
		aspect-ratio/abspos-007.html
		aspect-ratio/abspos-008.html
		aspect-ratio/abspos-009.html
		aspect-ratio/abspos-010.html
		aspect-ratio/abspos-011.html
		aspect-ratio/abspos-012.html
		aspect-ratio/abspos-013.html
		aspect-ratio/abspos-014.html
		aspect-ratio/abspos-015.html
		aspect-ratio/abspos-016.html
		aspect-ratio/abspos-017.html
		aspect-ratio/abspos-018.html
		aspect-ratio/abspos-019.html
		aspect-ratio/abspos-020.html
		aspect-ratio/abspos-021.html
		aspect-ratio/auto-margins-001.html
		aspect-ratio/block-aspect-ratio-001.html
		aspect-ratio/block-aspect-ratio-002.html
		aspect-ratio/block-aspect-ratio-003.html
		aspect-ratio/block-aspect-ratio-004.html
		aspect-ratio/block-aspect-ratio-005.html
		aspect-ratio/block-aspect-ratio-006.html
		aspect-ratio/block-aspect-ratio-007.html
		aspect-ratio/block-aspect-ratio-008.html
		aspect-ratio/block-aspect-ratio-009.html
		aspect-ratio/block-aspect-ratio-010.html
		aspect-ratio/block-aspect-ratio-011.html
		aspect-ratio/block-aspect-ratio-012.html
		aspect-ratio/block-aspect-ratio-013.html
		aspect-ratio/block-aspect-ratio-014.html
		aspect-ratio/block-aspect-ratio-015.html
		aspect-ratio/block-aspect-ratio-016.html
		aspect-ratio/block-aspect-ratio-017.html
		aspect-ratio/block-aspect-ratio-018.html
		aspect-ratio/block-aspect-ratio-019.html
		aspect-ratio/block-aspect-ratio-020.html
		aspect-ratio/block-aspect-ratio-021.html
		aspect-ratio/block-aspect-ratio-022.html
		aspect-ratio/block-aspect-ratio-023.html
		aspect-ratio/block-aspect-ratio-024.html
		aspect-ratio/block-aspect-ratio-025.html
		aspect-ratio/block-aspect-ratio-026.html
		aspect-ratio/block-aspect-ratio-027.html
		aspect-ratio/block-aspect-ratio-028.html
		aspect-ratio/block-aspect-ratio-029-crash.html
		aspect-ratio/block-aspect-ratio-030.html
		aspect-ratio/block-aspect-ratio-031.html
		aspect-ratio/block-aspect-ratio-032.html
		aspect-ratio/block-aspect-ratio-033.html
		aspect-ratio/block-aspect-ratio-034.html
		aspect-ratio/block-aspect-ratio-035.html
		aspect-ratio/block-aspect-ratio-036.html
		aspect-ratio/block-aspect-ratio-037.html
		aspect-ratio/block-aspect-ratio-051-crash.html
		aspect-ratio/block-aspect-ratio-052.html
		aspect-ratio/block-aspect-ratio-053.html
		aspect-ratio/block-aspect-ratio-054.html
		aspect-ratio/block-aspect-ratio-055.html
		aspect-ratio/block-aspect-ratio-056.html
		aspect-ratio/block-aspect-ratio-058.html
		aspect-ratio/block-aspect-ratio-with-margin-collapsing-001.html
		aspect-ratio/block-aspect-ratio-with-margin-collapsing-002.html
		aspect-ratio/box-sizing-dimensions.html
		aspect-ratio/box-sizing-squashed.html
		aspect-ratio/flex-aspect-ratio-001.html
		aspect-ratio/flex-aspect-ratio-003.html
		aspect-ratio/flex-aspect-ratio-005.html
		aspect-ratio/flex-aspect-ratio-006.html
		aspect-ratio/flex-aspect-ratio-007.html
		aspect-ratio/flex-aspect-ratio-008.html
		aspect-ratio/flex-aspect-ratio-009.html
		aspect-ratio/flex-aspect-ratio-010.html
		aspect-ratio/flex-aspect-ratio-011.html
		aspect-ratio/flex-aspect-ratio-012.html
		aspect-ratio/flex-aspect-ratio-013.html
		aspect-ratio/flex-aspect-ratio-014.html
		aspect-ratio/flex-aspect-ratio-015.html
		aspect-ratio/flex-aspect-ratio-016.html
		aspect-ratio/flex-aspect-ratio-017.html
		aspect-ratio/flex-aspect-ratio-018.html
		aspect-ratio/flex-aspect-ratio-019.html
		aspect-ratio/flex-aspect-ratio-020.html
		aspect-ratio/flex-aspect-ratio-021.html
		aspect-ratio/flex-aspect-ratio-022.html
		aspect-ratio/flex-aspect-ratio-023.html
		aspect-ratio/flex-aspect-ratio-024.html
		aspect-ratio/flex-aspect-ratio-027.html
		aspect-ratio/flex-aspect-ratio-028.html
		aspect-ratio/flex-aspect-ratio-029.html
		aspect-ratio/flex-aspect-ratio-030.html
		aspect-ratio/flex-aspect-ratio-032.html
		aspect-ratio/flex-aspect-ratio-033.html
		aspect-ratio/flex-aspect-ratio-034.html
		aspect-ratio/flex-aspect-ratio-035.html
		aspect-ratio/flex-aspect-ratio-036.html
		aspect-ratio/flex-aspect-ratio-037.html
		aspect-ratio/flex-aspect-ratio-038.html
		aspect-ratio/flex-aspect-ratio-045.html
		aspect-ratio/flex-aspect-ratio-046.html
		aspect-ratio/flex-aspect-ratio-047.html
		aspect-ratio/flex-aspect-ratio-048.html
		aspect-ratio/flex-aspect-ratio-049.html
		aspect-ratio/flex-aspect-ratio-050.html
		aspect-ratio/flex-aspect-ratio-051.html
		aspect-ratio/flex-aspect-ratio-052.html
		aspect-ratio/flex-aspect-ratio-053.html
		aspect-ratio/flex-aspect-ratio-054.html
		aspect-ratio/flex-aspect-ratio-055.html
		aspect-ratio/floats-aspect-ratio-001.html
		aspect-ratio/fractional-aspect-ratio.html
		aspect-ratio/grid-aspect-ratio-001.html
		aspect-ratio/grid-aspect-ratio-002.html
		aspect-ratio/grid-aspect-ratio-003.html
		aspect-ratio/grid-aspect-ratio-004.html
		aspect-ratio/grid-aspect-ratio-005.html
		aspect-ratio/grid-aspect-ratio-006.html
		aspect-ratio/grid-aspect-ratio-007.html
		aspect-ratio/grid-aspect-ratio-008.html
		aspect-ratio/grid-aspect-ratio-009.html
		aspect-ratio/grid-aspect-ratio-010.html
		aspect-ratio/grid-aspect-ratio-011.html
		aspect-ratio/grid-aspect-ratio-012.html
		aspect-ratio/grid-aspect-ratio-014.html
		aspect-ratio/grid-aspect-ratio-015.html
		aspect-ratio/grid-aspect-ratio-016.html
		aspect-ratio/grid-aspect-ratio-017.html
		aspect-ratio/grid-aspect-ratio-018.html
		aspect-ratio/grid-aspect-ratio-019.html
		aspect-ratio/grid-aspect-ratio-020.html
		aspect-ratio/grid-aspect-ratio-021.html
		aspect-ratio/grid-aspect-ratio-022.html
		aspect-ratio/grid-aspect-ratio-023.html
		aspect-ratio/grid-aspect-ratio-024.html
		aspect-ratio/grid-aspect-ratio-025.html
		aspect-ratio/grid-aspect-ratio-026.html
		aspect-ratio/grid-aspect-ratio-027.html
		aspect-ratio/grid-aspect-ratio-028.html
		aspect-ratio/grid-aspect-ratio-029.html
		aspect-ratio/grid-aspect-ratio-030.html
		aspect-ratio/grid-aspect-ratio-031.html
		aspect-ratio/grid-aspect-ratio-032.html
		aspect-ratio/grid-aspect-ratio-033.html
		aspect-ratio/grid-aspect-ratio-034.html
		aspect-ratio/grid-aspect-ratio-035.html
		aspect-ratio/grid-aspect-ratio-036.html
		aspect-ratio/grid-aspect-ratio-037.html
		aspect-ratio/grid-aspect-ratio-038.html
		aspect-ratio/grid-aspect-ratio-040.html
		aspect-ratio/grid-aspect-ratio-041.html
		aspect-ratio/inheritance.html
		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-011.html
		aspect-ratio/intrinsic-size-012.html
		aspect-ratio/intrinsic-size-013.html
		aspect-ratio/intrinsic-size-014.html
		aspect-ratio/intrinsic-size-015.html
		aspect-ratio/intrinsic-size-016.html
		aspect-ratio/intrinsic-size-017.html
		aspect-ratio/intrinsic-size-018.html
		aspect-ratio/intrinsic-size-019.html
		aspect-ratio/intrinsic-size-020.html
		aspect-ratio/intrinsic-size-021.html
		aspect-ratio/intrinsic-size-022.html
		aspect-ratio/intrinsic-size-023.html
		aspect-ratio/intrinsic-size-024.html
		aspect-ratio/intrinsic-size-025.html
		aspect-ratio/large-aspect-ratio-crash.html
		aspect-ratio/parsing/aspect-ratio-computed.html
		aspect-ratio/parsing/aspect-ratio-invalid.html
		aspect-ratio/parsing/aspect-ratio-valid.html
		aspect-ratio/percentage-resolution-001.html
		aspect-ratio/percentage-resolution-002.html
		aspect-ratio/percentage-resolution-003.html
		aspect-ratio/percentage-resolution-004.html
		aspect-ratio/percentage-resolution-005.html
		aspect-ratio/quirks-mode-001.html
		aspect-ratio/quirks-mode-002.html
		aspect-ratio/quirks-mode-003.html
		aspect-ratio/replaced-element-001.html
		aspect-ratio/replaced-element-002.html
		aspect-ratio/replaced-element-003.html
		aspect-ratio/replaced-element-004.html
		aspect-ratio/replaced-element-005.html
		aspect-ratio/replaced-element-006.html
		aspect-ratio/replaced-element-007.html
		aspect-ratio/replaced-element-008.html
		aspect-ratio/replaced-element-009.html
		aspect-ratio/replaced-element-010.html
		aspect-ratio/replaced-element-011.html
		aspect-ratio/replaced-element-012.html
		aspect-ratio/replaced-element-013.html
		aspect-ratio/replaced-element-014.html
		aspect-ratio/replaced-element-015.html
		aspect-ratio/replaced-element-016.html
		aspect-ratio/replaced-element-017.html
		aspect-ratio/replaced-element-018.html
		aspect-ratio/replaced-element-019.html
		aspect-ratio/replaced-element-020.html
		aspect-ratio/replaced-element-021.html
		aspect-ratio/replaced-element-022.html
		aspect-ratio/replaced-element-023.html
		aspect-ratio/replaced-element-024.html
		aspect-ratio/replaced-element-025.html
		aspect-ratio/replaced-element-026.html
		aspect-ratio/replaced-element-027.html
		aspect-ratio/replaced-element-028.html
		aspect-ratio/replaced-element-029.html
		aspect-ratio/replaced-element-030.html
		aspect-ratio/replaced-element-031.html
		aspect-ratio/replaced-element-034.html
		aspect-ratio/replaced-element-035.html
		aspect-ratio/replaced-element-036.html
		aspect-ratio/replaced-element-037.html
		aspect-ratio/replaced-element-042.html
		aspect-ratio/replaced-element-045.html
		aspect-ratio/replaced-element-046.html
		aspect-ratio/replaced-element-049.html
		aspect-ratio/replaced-element-dynamic-aspect-ratio.html
		aspect-ratio/select-element-001.html
		aspect-ratio/sign-function-aspect-ratio.html
		aspect-ratio/small-aspect-ratio-crash.html
		aspect-ratio/table-element-001.html
		aspect-ratio/zero-or-infinity-001.html
		aspect-ratio/zero-or-infinity-002.html
		aspect-ratio/zero-or-infinity-003.html
		aspect-ratio/zero-or-infinity-004.html
		aspect-ratio/zero-or-infinity-005.html
		aspect-ratio/zero-or-infinity-006.html
		aspect-ratio/zero-or-infinity-007.html
		aspect-ratio/zero-or-infinity-008.html
		aspect-ratio/zero-or-infinity-009.html
		aspect-ratio/zero-or-infinity-010.html
	</wpt>

	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.

	<dl dfn-for="aspect-ratio" dfn-type="value">
		<dt><dfn>auto</dfn>
		<dd>
			<a>Replaced elements</a> with a <a>natural aspect ratio</a>
			use that aspect ratio;
			otherwise the box has no <a>preferred aspect ratio</a>.
			Size calculations involving the aspect ratio
			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 the aspect ratio
			work with the dimensions of the box specified by 'box-sizing'.

			If the <<ratio>> is [=degenerate ratio|degenerate=],
			the property instead behaves as ''aspect-ratio/auto''.

		<dt><dfn>auto && <<ratio>></dfn>
		<dd>
			If both ''aspect-ratio/auto'' and a <<ratio>> are specified together,
			the [=preferred aspect ratio=] is the specified ratio
			of ''<var>width</var> / <var>height</var>''
			unless it is a [=replaced element=] with a [=natural aspect ratio=],
			in which case that aspect ratio is used instead.
			In all cases, size calculations involving the aspect ratio
			work with the [=content box=] dimensions always.

			If the <<ratio>> is [=degenerate ratio|degenerate=],
			the property instead behaves as ''aspect-ratio/auto''.

			<wpt>
				aspect-ratio/block-aspect-ratio-050.html
			</wpt>
	</dl>

	Note: Having a [=preferred aspect ratio=] does not make a box into a [=replaced element=];
	layout rules specific to [=replaced elements=]
	do not generally apply to [=non-replaced=] boxes with a [=preferred aspect ratio=].
	For example, a [=non-replaced=] [=absolutely-positioned=] box
	treats ''justify-self: normal'' as ''justify-self/stretch'', not as ''justify-self/start''
	([[CSS-ALIGN-3#justify-abspos]]),
	even if it has a [=preferred aspect ratio=]

	ISSUE: CSS2.1 does not cleanly differentiate between
	replaced elements vs. elements with an aspect ratio;
	need to figure out specific cases that are unclear and define them,
	either in the appropriate Level 3 spec or here.

	<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 number) / 1) {
			  iframe {
			    aspect-ratio: attr(width number) / attr(height number);
			    width: 100%;
			    height: auto;
			  }
			}
		</pre>
	</div>

	If a replaced element's only [=natural dimension=]
	is a [=natural width=] or a [=natural height=],
	giving it a [=preferred aspect ratio=]
	also gives it an [=natural dimensions|natural=] height or width,
	whichever was missing,
	by transferring the existing size
	through the [=preferred aspect ratio=].

<h3 id="aspect-ratio-automatic">
Effects of Preferred Aspect Ratio on Automatic Sizes</h3>

	When a box has a [=preferred aspect ratio=],
	its <a>automatic sizes</a>
	are calculated the same as for
	a [=replaced element=] with a [=natural aspect ratio=]
	and no [=natural size=] in that axis,
	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 export>ratio-dependent axis</dfn>,
	and the resulting size is <a>definite</a>
	if its input sizes are also <a>definite</a>.
	The opposite axis (on which the [=ratio-dependent axis=] size depends)
	is the <dfn export>ratio-determining axis</dfn>.

	Note: A [=preferred aspect ratio=]
	only ever has an effect if at least one of the box's sizes
	is [=automatic size|automatic=].
	If neither 'width' nor 'height' is an [=automatic size=],
	it can have no effect on its [=preferred sizes=].

	Issue: When we move all the sizing information here,
	rather than crowbar-ing our way into 2.1,
	then the core principle here is just:
	the resolved [=preferred size=] in the ratio-determining axis
	(before applying min/max)
	gets transferred thru the ratio.
	Min/max constraints get transferred afterwards,
	and then applied to each axis independently without regards to aspect-ratio.

	<wpt>
		aspect-ratio/flex-aspect-ratio-031.html
		aspect-ratio/grid-aspect-ratio-align-items-center.html
	</wpt>

<h4 id="aspect-ratio-margin-collapse">
Margin-collapsing</h4>

	For the purpose of margin collapsing ([[css2/box#collapsing-margins]]),
	if the [=block axis=] is the [=ratio-dependent axis=],
	it is not considered to have a [=computed value|computed=] 'block-size' of ''height/auto''.

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

	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> in that axis,
	is its <a>min-content size</a>
	capped by 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 highlight=css>
		  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
		(and handles overflow by becoming scrollable instead, as usual).

		<pre highlight=css>
		  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 highlight=css>
		  div {
		    aspect-ratio: 1/1;
		    min-height: 0;
		  }
		</pre>

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

	<div class="example">
		This automatic minimum operates in both axes.
		Consider this example:

		<pre highlight=html>
			&lt;div style="height: 100px; aspect-ratio: 1/1;">
				&lt;span style="display: inline-block; width: 50px;">&lt;/span>
				&lt;span style="display: inline-block; width: 150px;">&lt;/span>
			&lt;/div>
		</pre>

		The 'width' of the container, being ''width/auto'',
		resolves through the aspect ratio to 100px.
		However, its 'min-width', being ''min-width/auto'',
		resolves to 150px.
		The resulting width of the container is thus 150px.
		To ignore the contents when sizing the container,
		''min-width: 0'' can be specified.
	</div>

	<wpt>
		aspect-ratio/block-aspect-ratio-038.html
		aspect-ratio/block-aspect-ratio-039.html
		aspect-ratio/fieldset-element-001.html
		aspect-ratio/fieldset-element-002.html
		aspect-ratio/flex-aspect-ratio-002.html
		aspect-ratio/flex-aspect-ratio-004.html
		aspect-ratio/flex-aspect-ratio-025.html
		aspect-ratio/flex-aspect-ratio-026.html
		aspect-ratio/flex-aspect-ratio-040.html
		aspect-ratio/flex-aspect-ratio-041.html
		aspect-ratio/flex-aspect-ratio-042.html
		aspect-ratio/flex-aspect-ratio-043.html
		aspect-ratio/flex-aspect-ratio-044.html
		aspect-ratio/grid-aspect-ratio-039.html
		aspect-ratio/grid-aspect-ratio-042.html
		aspect-ratio/intrinsic-size-010.html
	</wpt>

<h3 id="aspect-ratio-size-transfers">
Min/Max Size Transfers</h3>

	Sizing constraints in either axis
	(the <var>origin</var> axis)
	are transferred through the [=preferred aspect ratio=]
	and applied to any [=indefinite=]
	[=minimum size|minimum=], [=maximum size|maximum=], or [=preferred size|preferred=] size
	in the other axis (the <var>destination</var> axis)
	as follows:

	* First, any [=definite=] [=minimum size=] is converted and transferred
		from the <var>origin</var> to <var>destination</var> axis.
		This transferred minimum is capped
		by any [=definite=] [=preferred size|preferred=] or [=maximum size=]
		in the <var>destination</var> axis.
	* Then, any [=definite=] [=maximum size=] is converted and transferred
		from the <var>origin</var> to <var>destination</var>.
		This transferred maximum is floored
		by any [=definite=] [=preferred size|preferred=] or [=minimum size=]
		in the <var>destination</var> axis
		as well as by the transferred minimum, if any.

	Note: Thus, any definite sizes are completely unaffected by a transferred constraint;
	and a transferred minimum will never cause an element to exceed a definite preferred/maximum size,
	nor will a transferred maximum cause an element to violate its preferred/minimum size.

	Note: The basic principle is that sizing constraints
	transfer through the aspect-ratio to the other side
	to preserve the aspect ratio to the extent that they can
	without violating any sizes specified explicitly on that affected axis.
	(This is the principle that drove the contents of
	the <a href="https://www.w3.org/TR/CSS2/visudet.html#min-max-widths">constraint table in CSS2 Section 10.4</a>.)

	<div class="example">
		In the following example:

		<pre highlight=html>
			&lt;div id=container style="height: 100px; float: left;">
				&lt;div id=item style="height: 100%; aspect-ratio: 1/1;">content&lt;/div>
			&lt;/div>
		</pre>

		Since the height of the <code>#item</code> is a percentage that resolves against a definite container,
		the width of the item resolves to 100px for both its intrinsic size contributions as well as for final layout,
		so the container also sizes to a width of 100px.

		<pre highlight=html>
			&lt;div id=container style="height: auto; float: left;">
				&lt;div id=item style="height: 100%; aspect-ratio: 1/1;">content&lt;/div>
			&lt;/div>
		</pre>

		In this next example,
		the percentage height of the item cannot be resolved and [=behaves as auto=]
		(see [[css2/visudet#the-height-property]]).
		Since both axes now have an [=automatic size=],
		the height becomes the [=ratio-dependent axis=].
		Calculating the [=intrinsic size contributions=] of the box
		produces a width derived from its content,
		and a height calculated from that width and the aspect ratio,
		yielding a square box (and a container) sized
		to the width of the word “content”.
	</div>

	<wpt>
		aspect-ratio/replaced-element-032.html
		aspect-ratio/replaced-element-033.html
		aspect-ratio/block-aspect-ratio-040.html
		aspect-ratio/block-aspect-ratio-041.html
		aspect-ratio/block-aspect-ratio-042.html
		aspect-ratio/block-aspect-ratio-043.html
		aspect-ratio/block-aspect-ratio-044.html
		aspect-ratio/block-aspect-ratio-045.html
		aspect-ratio/block-aspect-ratio-046.html
		aspect-ratio/block-aspect-ratio-047.html
		aspect-ratio/block-aspect-ratio-048.html
		aspect-ratio/block-aspect-ratio-049.html
		aspect-ratio/flex-aspect-ratio-039.html
		aspect-ratio/replaced-element-039.html
		aspect-ratio/replaced-element-040.html
		aspect-ratio/replaced-element-041.html
		aspect-ratio/replaced-element-043.html
		aspect-ratio/replaced-element-044.html
		image-max-width-and-height-behaves-as-auto.html
		min-max-content-orthogonal-flow-crash-001.html
	</wpt>

	ISSUE(6071): This section might not be written correctly.

<!-- Big Text: intrinsic

████ █    █▌ █████▌ ████▌  ████ █    █▌  ███▌  ████  ███▌ 
 ▐▌  █▌   █▌   █▌   █▌  █▌  ▐▌  █▌   █▌ █▌  █▌  ▐▌  █▌  █▌
 ▐▌  ██▌  █▌   █▌   █▌  █▌  ▐▌  ██▌  █▌ █▌      ▐▌  █▌    
 ▐▌  █▌▐█ █▌   █▌   ████▌   ▐▌  █▌▐█ █▌  ███▌   ▐▌  █▌    
 ▐▌  █▌  ██▌   █▌   █▌▐█    ▐▌  █▌  ██▌     █▌  ▐▌  █▌    
 ▐▌  █▌   █▌   █▌   █▌ ▐█   ▐▌  █▌   █▌ █▌  █▌  ▐▌  █▌  █▌
████ █▌   ▐▌   █▌   █▌  █▌ ████ █▌   ▐▌  ███▌  ████  ███▌ 
-->

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

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

	ISSUE: [[css-sizing-3#intrinsic-sizes]]

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

	<pre class=propdef>
	Name: contain-intrinsic-width, contain-intrinsic-height, contain-intrinsic-block-size, contain-intrinsic-inline-size
	Value: auto? [ none | <<length [0,∞]>> ]
	Initial: none
	Inherited: no
	Logical property group: contain-intrinsic-size
	Applies to: elements with [=size containment=]
	Computed value: as specified, with <<length>> values computed
	Percentages: n/a
	Animation type: by computed value type
	</pre>

	<wpt>
		contain-intrinsic-size/auto-014.html
		contain-intrinsic-size/auto-015.html
		contain-intrinsic-size/auto-016.html
		contain-intrinsic-size/auto-017.html
		contain-intrinsic-size/auto-018.html
		contain-intrinsic-size/contain-intrinsic-size-001.html
		contain-intrinsic-size/contain-intrinsic-size-002.html
		contain-intrinsic-size/contain-intrinsic-size-003.html
		contain-intrinsic-size/contain-intrinsic-size-004.html
		contain-intrinsic-size/contain-intrinsic-size-005.html
		contain-intrinsic-size/contain-intrinsic-size-006.html
		contain-intrinsic-size/contain-intrinsic-size-007.html
		contain-intrinsic-size/contain-intrinsic-size-008.html
		contain-intrinsic-size/contain-intrinsic-size-009.html
		contain-intrinsic-size/contain-intrinsic-size-010.html
		contain-intrinsic-size/contain-intrinsic-size-011.html
		contain-intrinsic-size/contain-intrinsic-size-012.html
		contain-intrinsic-size/contain-intrinsic-size-013.html
		contain-intrinsic-size/contain-intrinsic-size-014.html
		contain-intrinsic-size/contain-intrinsic-size-015.html
		contain-intrinsic-size/contain-intrinsic-size-016.html
		contain-intrinsic-size/contain-intrinsic-size-017.html
		contain-intrinsic-size/contain-intrinsic-size-018.html
		contain-intrinsic-size/contain-intrinsic-size-019.html
		contain-intrinsic-size/contain-intrinsic-size-020.html
		contain-intrinsic-size/contain-intrinsic-size-021.html
		contain-intrinsic-size/contain-intrinsic-size-022.html
		contain-intrinsic-size/contain-intrinsic-size-023.html
		contain-intrinsic-size/contain-intrinsic-size-024.html
		contain-intrinsic-size/contain-intrinsic-size-025.html
		contain-intrinsic-size/contain-intrinsic-size-026.html
		contain-intrinsic-size/contain-intrinsic-size-027.html
		contain-intrinsic-size/contain-intrinsic-size-028.html
		contain-intrinsic-size/contain-intrinsic-size-029.html
		contain-intrinsic-size/contain-intrinsic-size-030.html
		contain-intrinsic-size/contain-intrinsic-size-031.html
		contain-intrinsic-size/contain-intrinsic-size-032.html
		contain-intrinsic-size/contain-intrinsic-size-logical-001.html
		contain-intrinsic-size/contain-intrinsic-size-logical-002.html
		contain-intrinsic-size/contain-intrinsic-size-logical-003.html
		contain-intrinsic-size/forget-on-disconnect-in-iframe.html
		contain-intrinsic-size/parsing/contain-intrinsic-size-computed.html
		contain-intrinsic-size/parsing/contain-intrinsic-size-invalid.html
		contain-intrinsic-size/parsing/contain-intrinsic-size-valid.html
	</wpt>

	These properties allow elements with [=size containment=] to specify
	an <dfn export>explicit intrinsic inner size</dfn>,
	causing the box to size as if its [=in-flow=] content
	totals to a width and height
	matching the specified [=explicit intrinsic inner size=]
	(rather than sizing as if it were empty).

	Note: This is not always equivalent
	to laying out as if the element had one child of the specified [=explicit intrinsic inner size=].
	For example, a [=grid container=] with one child of the specified size
	would still size according to the specified grid,
	usually ending up with a larger content size than specified.

	<wpt>
		contain-intrinsic-size/contain-intrinsic-size-033.html
	</wpt>

	<dl dfn-type=value dfn-for="contain-intrinsic-width, contain-intrinsic-height, contain-intrinsic-block-size, contain-intrinsic-inline-size, contain-intrinsic-size">
		: <dfn>none</dfn> | <dfn><<length>></dfn>
		::
			If no other 'contain-intrinsic-size' value
			(such as ''contain-intrinsic-size/auto'')
			is providing an [=explicit intrinsic inner size=],
			the corresponding axis either doesn't have an [=explicit intrinsic inner size=]
			(if ''contain-intrinsic-size/none'' is specified)
			or has an [=explicit intrinsic inner size=] of the specified <<length>>.

		: <dfn>auto</dfn>
		:: If ''contain-intrinsic-size/auto'' is specified
			and the element has a [=last remembered size=]
			and is currently [=skipping its contents=],
			its [=explicit intrinsic inner size=] in the corresponding axis
			is the [=last remembered size=] in that axis.

			Note: This occurs, for example,
			when an element with ''content-visibility: auto''
			is off-screen.

			<wpt pathprefix="css/css-contain/">
			content-visibility/content-visibility-058.html
			</wpt>
	</dl>

	If an element has an [=explicit intrinsic inner size=] in an axis,
	then after laying out the element as normal for [=size containment=],
	the size of the contents in that axis are instead treated as being the [=explicit intrinsic inner size=]
	instead of what was calculated in layout,
	and layout is performed again if necessary.
	(If it has an [=explicit intrinsic inner size=] in both axises,
	this implies the first layout can be skipped.)

	These four properties are part of a [=logical property group=].

	Note: An element with [=size containment=] is laid out as if it had no contents [[!CSS-CONTAIN-1]],
	which in many cases this will cause the element to collapse to zero inner height.
	This can be corrected with an explicit 'height' chosen to show the expected contents,
	but that can have unintended effects in some layout systems,
	such as Flex and Grid Layout,
	which treat an explicit 'height' as a stronger command
	than an implicit content-based height.
	The element thus might lay out substantially differently than it would have
	were it simply filled with content up to that height.
	Providing an [=explicit intrinsic inner size=] for the element
	preserves the performance benefits of ignoring its contents for layout
	while still allowing it to size as if it had content.

	<pre class="propdef shorthand">
	Name: contain-intrinsic-size
	Value: [ auto? [ none | <<length [0,∞]>> ] ]{1,2}
	</pre>

	<wpt>
		contain-intrinsic-size/animation/contain-intrinsic-size-interpolation.html
	</wpt>

	'contain-intrinsic-size' is a shorthand property
	that sets the 'contain-intrinsic-width' and 'contain-intrinsic-height' properties.

	The first value represents the 'contain-intrinsic-width' value,
	and the second represents the 'contain-intrinsic-height' value.
	If only one value is given,
	it applies to both properties.

<h4 id='last-remembered' dfn lt="last remembered size" export>
Last Remembered Size</h4>

	[=Size containment=] is very valuable for ensuring a page can render efficiently,
	restricting the scope of layout work that can happen
	as a result of an element changing its rendering.
	However, it's also very restrictive for the author,
	requiring them to correctly predict what the size of the element will be;
	if this guess is incorrect,
	even slightly,
	it can cause unsightly scrollbars or accidentally-hidden content.

	The ''contain-intrinsic-size/auto'' keyword of ''contain-intrinsic-size'' allows a middle-ground:
	if an element is ever <em>not</em> [=size containment|size-contained=],
	this value causes the element to remember its size
	(calculated as normal by layout);
	then, if the element gains [=size containment=] later,
	it will use the remembered size,
	offering the performance benefits of [=size containment=]
	while <em>probably</em> sizing accurately to its contents.

	Only elements capable of being {{ResizeObserver}} targets can have a [=last remembered size=].

	<div algorithm="last remembered size">
		The [=last remembered size=] of an element is determined by:

		* At the time that {{ResizeObserver}} events are determined and delivered,
			if an element has a ''contain-intrinsic-size/auto'' keyword in ''contain-intrinsic-size'' property,
			is capable of being a {{ResizeObserver}} target,
			but does not have [=size containment=],
			record the current inner dimensions of its [=principal box=]
			as its [=last remembered size=].

		* At the time that {{ResizeObserver}} events are determined and delivered,
			if an element has a [=last remembered size=]
			but does <em>not</em> have ''contain-intrinsic-size/auto'' keyword in ''contain-intrinsic-size'' property,
			remove its [=last remembered size=].

		Note: The [=last remembered size=] is state attached to the <em>element</em>,
		not any particular box generated by the element.
		So long as the element retains ''contain-intrinsic-size/auto'' keyword in ''contain-intrinsic-size'' property,
		it will remember its [=last remembered size=]
		even across changes such as going to/from ''display: none''.
	</div>

	<wpt>
		contain-intrinsic-size/auto-001.html
		contain-intrinsic-size/auto-002.html
		contain-intrinsic-size/auto-003.html
		contain-intrinsic-size/auto-004.html
		contain-intrinsic-size/auto-005.html
		contain-intrinsic-size/auto-006.html
		contain-intrinsic-size/auto-007.html
		contain-intrinsic-size/auto-008.html
		contain-intrinsic-size/auto-009.html
		contain-intrinsic-size/auto-010.html
		contain-intrinsic-size/auto-011.html
		contain-intrinsic-size/auto-012.html
		contain-intrinsic-size/auto-013.html
	</wpt>


<h4 id='cis-scrollbars'>
Interaction With ''overflow: auto''</h4>

	The 'contain-intrinsic-size' property provides an estimate
	of how large the author expects the content of an element to be,
	but this estimate is not actual content
	and does not represent anything that needs to be shown to the user.
	Therefore, an element with ''overflow: auto'' must not generate scrollbars
	as a consequence of 'contain-intrinsic-size'.

	However, if 'contain-intrinsic-size' indicates a size large enough
	that the element would generate scrollbars
	if it contained actual content of that size,
	then the element must be <em>sized</em> as if it generated those scrollbar(s)
	in accordance with such hypothetical content.

	<div class='example'>
		In the following example code:

		<pre highlight=css>
		div {
			width: max-content;
			contain-intrinsic-size: 100px 100px;
			overflow: auto;
		}
		</pre>

		The element ends up being ''100px'' wide and ''100px'' tall:
		'contain-intrinsic-size' provides the max-content width,
		and also the height.

		If the element then ended up with content that was ''150px'' tall,
		it would show a vertical scrollbar;
		if the scrollbar is not overlay,
		it will take up some of that ''100px'' width,
		leaving a smaller amount
		(roughly ''84px'', typically)
		for the content to flow into.
		(See [[css-overflow-3#scrollbar-layout]].)

		Even though there's now less than ''100px'' of horizontal space available for the content,
		it will not generate a horizontal scrollbar just because 'contain-intrinsic-size' indicates a ''100px'' width;
		that would only happen if the actual content
		had something unbreakable
		and wider than the remaining space.
	</div>

	<div class=example>
		In contrast, in the following example code:

		<pre highlight=css>
		div {
			width: max-content;
			contain-intrinsic-size: 100px 100px;
			height: 50px;
			overflow: auto;
		}
		</pre>

		The element has a fixed ''50px'' height,
		but 'contain-intrinsic-size' indicates a ''100px'' “estimated content height”.
		The element thus assumes that it will need a vertical scrollbar
		when it's filled with actual content,
		resulting in a max-content width a little more than ''100px''
		(roughly ''116px'', typically),
		to accommodate the estimated ''100px'' of max-content width from 'contain-intrinsic-size',
		and as well as the vertical scrollbar width (roughly ''16px'', typically).

		However, even though the element reserves space on the assumption of needing a scrollbar,
		it will not actually generate one
		unless the actual content overflows:
		if it ends up containing content that's less than 50px tall,
		no vertical scrollbar will be generated at all,
		but the element will still be ''116px'' wide.
	</div>


<!-- Big Text: contribs

 ███▌   ███▌  █    █▌ █████▌ ████▌  ████ ████▌   ███▌ 
█▌  █▌ █▌  █▌ █▌   █▌   █▌   █▌  █▌  ▐▌  █▌  █▌ █▌  █▌
█▌     █▌  █▌ ██▌  █▌   █▌   █▌  █▌  ▐▌  █▌  █▌ █▌    
█▌     █▌  █▌ █▌▐█ █▌   █▌   ████▌   ▐▌  █████   ███▌ 
█▌     █▌  █▌ █▌  ██▌   █▌   █▌▐█    ▐▌  █▌  █▌     █▌
█▌  █▌ █▌  █▌ █▌   █▌   █▌   █▌ ▐█   ▐▌  █▌  █▌ █▌  █▌
 ███▌   ███▌  █▌   ▐▌   █▌   █▌  █▌ ████ ████▌   ███▌ 
-->

<h3 id='responsive-iframes' dfn lt="responsively-sized iframe" export>
Responsively-sized iframes: the 'frame-sizing' property</h3>

	<pre class="propdef">
	Name: frame-sizing
	Value: auto | content-width | content-height | content-block-size | content-inline-size
	Initial: auto
	Applies to: replaced elements (but see below for details)
	Inherited: no
	Computed value: as specified
	Animation type: discrete
	</pre>

	Some [=replaced elements=] can contain "normal" flowed content,
	such as HTML <{iframe}>s.
	For privacy and security reasons,
	these elements do not, by default,
	expose any information about their internal contents' sizing
	to the outside page,
	instead just using a static, predetermined intrinsic size,
	and making their contents scrollable.
	The 'frame-sizing' property
	allows these elements to opt into exposing their actual content size,
	known as their <dfn export>internal layout intrinsic size</dfn>.
	Values have the following meaning:

	<dl dfn-type=value dfn-for=frame-sizing>
		: <dfn>auto</dfn>
		::
			The element's [=internal layout intrinsic size=],
			if any,
			is ignored.

		: <dfn>content-width</dfn>
		: <dfn>content-height</dfn>
		: <dfn>content-block-size</dfn>
		: <dfn>content-inline-size</dfn>
		::
			If the element has an [=internal layout intrinsic size=],
			its [=intrinsic size=]
			takes the corresponding dimension
			(either width or height)
			from the [=internal layout intrinsic size=].
			(The other dimension is determined normally.)

			Logical directions resolve based on the [=writing mode=] of the element.
			(Not the embedded document.)
	</dl>

	Which elements can have an [=internal layout intrinsic size=],
	and how it's determined,
	are decided by the [=document language=].
	In HTML, only <{iframe}> elements can have an [=internal layout intrinsic size=],
	and further,
	only when the contained document has also opted in
	via a <code highlight=html>&lt;meta name=responsive-embedded-sizing></code> element.
	(See [[#iframe-frame-sizing]].)

	<div class='example'>
		When the embedded document has the following HTML:

	  <xmp highlight=html>
			<meta name="responsive-embedded-sizing">
			<div style="height: 500px"></div>
		</xmp>

		and the embedding document has the following CSS:

	  <pre highlight=css>
			iframe {
				frame-sizing: content-height;
			}
		</pre>

		The height of the <{iframe}> will initially be the default iframe height (typically ''150px''),
		but will be updated to ''500px'' once the iframe's document loads.
	</div>

	In addition,
	the internal document can call {{Window/requestResize()|window.requestResize()}}
	to update its [=internal layout intrinsic size=] later.


<h4 id=iframe-frame-sizing>
HTML <{iframe}> Details</h4>

	In HTML, only the <{iframe}> element can have an [=internal layout intrinsic size=],
	and only when the <{iframe}>'s embedded document has opted in appropriately.

	An HTML {{Document}} object
	has an <dfn for=Document>responsive embedded sizing flag</dfn> associated with it,
	which is initially unset.
	It is set to true or false
	during the initial document parse,
	depending on which of the following first occurs:

	* If a <code highlight=html>&lt;meta name=responsive-embedded-sizing></code> element is encountered,
		it is set to true.
	* If the <{body}> element is opened (explicitly or implicitly),
		or inserted into the document by the parser,
		it is set to false.

	Once set to either true or false,
	the flag will not change its value again for the lifetime of the {{Document}}.

	Note: Currently, the HTML <{meta}> element appearing in the <{head}> of an HTML document
	is the only way for an embedded document to opt into this feature in HTML.
	This means that SVG documents in <{iframe}> cannot do so.

	Note: Due to quirks of the HTML parser,
	a <{meta}> element can technically appear <em>between</em> the <{head}> and <{body}> elements,
	and will be reparented into the <{head}>.
	This is still a valid location for the <code>&lt;meta name=responsive-embedded-sizing></code> element,
	as the <{body}> has not yet been opened.
	Note that most HTML elements will implicitly open a <{body}> element
	even if the <{body}> start tag is not present,
	and if the document completely lacks such an element,
	an empty one is automatically generated and inserted.

	The [=internal layout intrinsic size=] is first set
	by the results of the embedded document's first layout
	after it fires its {{DOMContentLoaded}} event,
	and again when the {{Window/load}} event is fired at the {{Window}}.
	Subsequent changes to content, styling or layout of the embedded document
	do not automatically affect the [=internal layout intrinsic size=],
	but see {{Window/requestResize()}}.

	An embedded document can additionally have a <dfn>locked embedded ICB size</dfn>,
	which is initially null.
	If the document's [=responsive embedded sizing flag=] is true
	when it performs a layout,
	and its [=locked embedded ICB size=] is null,
	it records its current [=initial containing block=] size as its [=locked embedded ICB size=].
	On subsequent layouts,
	it uses its [=locked embedded ICB size=]
	instead of calculating its [=initial containing block=] size normally.

	Note: This freezing of the ICB
	reduces the chance of layout loops
	(an iframe document sizing to slightly larger than its ICB,
	then the parent iframe changing size to match,
	and the next layout again making it slightly larger than the ICB,
	etc to infinity).

	Issue: Do we want to have a way to force an iframe to forget its [=locked embedded ICB size=]?
	Maybe turning 'frame-sizing' off and on again?

	Navigating the iframe's document
	causes it to forget its [=locked embedded ICB size=].
	It <strong>does not</strong> forget its [=internal layout intrinsic size=]
	as long as the new document's [=responsive embedded sizing flag=] is unset.
	Once the flag is set (to true <em>or</em> false),
	the [=internal layout intrinsic size=] is forgotten;
	if the flag is set to true,
	both are then freshly computed as normal.


<h4 id=window-requestresize>
Extensions to the {{Window}} Interface</h4>

	<xmp class=idl>
	partial interface Window {
		undefined requestResize();
	};
	</xmp>

	<div algorithm>
		When <dfn for=Window method>requestResize()</dfn> is invoked:

		1. Let |navigable| be the [=/navigable=] that has [=this=] as its <l spec=html>[=content window=]</l>.
			If |navigable| is not a [=child navigable=],
			[=throw=] a {{NotAllowedError}} {{DOMException}}.

		1. Let |host element| be the [=navigable container=] whose [=content navigable=] is |navigable|.
			If |host element| is not an HTML <{iframe}> element,
			[=throw=] a {{NotAllowedError}} {{DOMException}}.

		1. Let |document| be [=this's=] [=active document=].
			If |document|'s [=Document/responsive embedded sizing flag=]
			is unset or false,
			[=throw=] a {{NotAllowedError}} {{DOMException}}.

		1. If |document| has pending style or layout changes,
			perform them.

		1. Set the [=internal layout intrinsic size=] of |host element|
			to the width and height of the <l spec=cssom-view>[=scrolling area=]</l> of [=this=].
	</div>


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

	ISSUE: [[css-sizing-3#intrinsic-contribution]]

<h3 id='intrinsic-contribution-override'>
Zeroing Min-Content Size Contributions: the 'min-intrinsic-sizing' property</h3>

	<pre class="propdef">
	Name: min-intrinsic-sizing
	Value: legacy | zero-if-scroll || zero-if-extrinsic
	Initial: legacy
	Inherited: no
	Applies to: all elements except [=inline boxes=]
	Computed value: as specified
	Percentages: n/a
	Animation type: discrete
	</pre>

	ISSUE: This property seriously needs some name bikeshedding.

	This property defines whether the [=min-content contribution=]
	of a [=non-replaced=] box
	is “compressed” under certain circumstances.
	Values have the following meanings:

	<dl dfn-for=min-intrinsic-sizing dfn-type=value>
		<dt><dfn>legacy</dfn>
		<dd>
			The box’s [=min-content contribution=]
			is handled as normal.

		<dt><dfn>zero-if-scroll</dfn>
		<dd>
			The box’s [=min-content contribution=]
			is “compressed” if it is a [=scroll container=] in that axis.

		<dt><dfn>zero-if-extrinsic</dfn>
		<dd>
			The box’s [=min-content contribution=]
			is “compressed” if has an [=extrinsic size|extrinsic=]
			[=preferred size|preferred=] or [=maximum size|maximum=] size.

			Note: This is the default behavior of most [=replaced elements=].
	</dl>

	<div class="example">
		The following rule will make all [=scroll containers=]
		essentially ignore their contents
		when passing up their size contributions
		(unless they specifically requested a content-based size):

		<pre highlight=css>*, ::before, ::after { min-intrinsic-size: zero-if-scroll; }</pre>

		This prevents the [=scroll container=] from blowing up the size of its ancestors
		if it contains large items such as a table or long lines of unbreakable text.
		Meanwhile, it allows boxes that are not scroll containers
		to continue influencing the [=min-content size=] of their ancestors.
	</div>

	Note: The behavior of ''zero-if-scroll'' would have been a better default,
	but due to Web-compat, it cannot be the initial value. :(

	The “compressed” [=min-content contributions=] is calculated
	by pretending the box were empty,
	except when factoring in sizing constraints imposed by explicit
	''width/min-content'', ''width/max-content'', and ''width/fit-content'' values
	of the [=sizing properties=].

<!-- Big Text: extrinsic

█████▌ █     █ █████▌ ████▌  ████ █    █▌  ███▌  ████  ███▌ 
█▌      █   █    █▌   █▌  █▌  ▐▌  █▌   █▌ █▌  █▌  ▐▌  █▌  █▌
█▌       █ █     █▌   █▌  █▌  ▐▌  ██▌  █▌ █▌      ▐▌  █▌    
████      █      █▌   ████▌   ▐▌  █▌▐█ █▌  ███▌   ▐▌  █▌    
█▌       █ █     █▌   █▌▐█    ▐▌  █▌  ██▌     █▌  ▐▌  █▌    
█▌      █   █    █▌   █▌ ▐█   ▐▌  █▌   █▌ █▌  █▌  ▐▌  █▌  █▌
█████▌ █     █   █▌   █▌  █▌ ████ █▌   ▐▌  ███▌  ████  ███▌ 
-->

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

	ISSUE: [[css-sizing-3#extrinsic]]

<h3 id="stretch-fit-sizing">
Stretch-fit Sizing: filling the containing block</h3>

	Stretch-fit sizing tries to set the box’s used size
	to the length necessary
	to make its [=principal box=]’s [=outer size=]
	as close to filling the [=containing block=] as possible
	while still respecting the constraints imposed by
	'min-height'/'min-width'/'max-height'/'max-width'.

	: If used in an axis where the relevant [=self-alignment property=] applies to the element
	::
		Typically produces the same size that would be obtained
		by the [=self-alignment property=] in that axis
		being set to ''justify-self/stretch''
		all [=sizing properties=] and 'aspect-ratio'
		being set to their initial values,
		and ''margin/auto'' margins treated as zero.

		Note: In [=multi-line flex container|multi-line=] [=flex layout=],
		the [=stretch-fit size=] resolves against the [=containing block=]
		and contributes that size to the [=cross size=] of the line--
		whereas ''align-self/stretch'' contributes the [=fit-content size=]--
		before finally resolving against the [=cross size=] of the line.

	: Otherwise, if used in an axis where percentage sizes can resolve to a [=definite=] value
	::
		Behaves as ''100%'',
		except it sizes the [=margin box=]
		regardless of the value of 'box-sizing'.

		If this is a [=block axis=] size,
		and the element is in a Block Layout [=formatting context=],
		and the parent element does not have a [=block-start=] 'border' or 'padding'
		and is not an [=independent formatting context=],
		treat the element's [=block-start=] margin as zero
		for the purpose of calculating this size.
		Do the same for the [=block-end=] margin.

		Note: This simulates the effect of margins collapsing with the parent's margin.
		It doesn't actually suppress the margins,
		so if anything prevents the element from actually collapsing with its parent,
		the [=stretch-fit size=] might actually be too large
		to fit in the parent perfectly.

		<!--
		Importantly, this *does* ensure that the stretch-fit size
		doesn't depend on the presence or absence of other elements,
		or the element's position among its siblings.
		Multiple children with 'stretch' will all end up the same size.
		-->

	: Otherwise
	::
		In a [=preferred size property=],
		[=behaves as auto=].
		In a [=min size property=],
		behaves as ''0''.
		In a [=max size property=],
		behaves as ''max-width/none''.

	<div class="example">
		For example, given the following HTML representing two [=block boxes=]:

		<xmp class=html>
		  <div class="parent">
		    <div class="child">text</div>
		  </div>
		</xmp>

		In the following case,
		the [=outer height=] of the child box
		will exactly match the height of the parent box (200px),
		but its [=inner height=] will be 20px less, to account for its margins.

		<pre>
		  .parent { height: 200px; border: solid; }
		  .child { height: stretch; margin: 10px; }
		</pre>

		On the other hand,
		in this case we can assume that the child's margins will collapse with the parent,
		so the inner box will be ''200px'' tall,
		exactly filling the parent.

		<pre>
		  .outer { height: 200px; margin: 0; }
		  .inner { height: stretch; margin: 10px; }
		</pre>

		(The top margins will in fact collapse,
		but the bottom margins do not collapse,
		because the bottom margin of a box is not adjoining
		to the bottom margin of a parent with a non-''height/auto'' height,
		see [[css2/box#collapsing-margins]].
		Luckily, an overflowing bottom margin doesn't have any visible effect.)
	</div>

	<div class="example">
		Similarly, ''width: stretch'' causes the box to fill its container,
		being 20px narrower than the width of "some more text"
		(due to the 10px margin):

		<pre class=html>
		  &lt;div class="parent">
		    &lt;div class="child">text&lt;/div>
		  &lt;/div>
		  some more text
		</pre>

		<pre>
			.parent { float: left; margin: 0; }
			.child { width: stretch; margin: 10px; }
		</pre>
	</div>

	<div class="example">
		On the other hand,
		in this example the container's height is indefinite,
		which would cause a percentage height on the child to [=behave as auto=],
		so ''height: stretch'' [=behaves as auto=] as well.

		<pre>
		  .parent { height: auto; margin: 0; }
		  .child { height: stretch; margin: 10px; }
		</pre>
	</div>

	<wpt>
		stretch/abspos-1.html
		stretch/abspos-2.html
		stretch/aspect-ratio-1.html
		stretch/aspect-ratio-2.html
		stretch/auto-margins-1.html
		stretch/auto-margins-2.html
		stretch/bfc-next-to-float-1.html
		stretch/bfc-next-to-float-2.html
		stretch/block-height-002.html
		stretch/block-height-003.html
		stretch/block-height-004.html
		stretch/block-height-005.html
		stretch/block-height-006.html
		stretch/block-height-007.html
		stretch/block-height-008.html
		stretch/block-height-009.html
		stretch/block-height-010.html
		stretch/cache-miss-001.html
		stretch/cache-miss-002.html
		stretch/content-contribution-001.html
		stretch/fixed-table-1.html
		stretch/flex-basis-1.html
		stretch/flexbox-auto-minimum-001.html
		stretch/flexbox-auto-minimum-002.html
		stretch/flexbox-flex-base-size-001.html
		stretch/flexbox-flex-base-size-002.html
		stretch/flexbox-stretch-minimum-001.html
		stretch/flexbox-stretch-minimum-002.html
		stretch/indefinite-1.html
		stretch/indefinite-2.html
		stretch/indefinite-3.html
		stretch/indefinite-4.html
		stretch/replaced-next-to-float-1.html
		stretch/replaced-next-to-float-2.html
		stretch/stretch-table-001.html
	</wpt>

<h3 id="contain-fit-sizing" dfn lt="contain-fit sizing" export>
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 [=preferred 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 [=preferred 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>

<h3 class=no-num id="changes-2021-05">
Changes since 5 May 2021 Working Draft</h3>

	Significant changes since the <a href="https://www.w3.org/TR/2021/WD-css-sizing-4-20210520/">5 May 2021 Working Draft</a> include:

	* Disallowed re-ordering of values in ''contain-intrinsic-size''.
		(<a href="https://github.com/w3c/csswg-drafts/issues/6391">Issue 6391</a>).
	* Only used the last remembered size for the ''contain-intrinsic-width/auto'' value of the 'contain-intrinsic-*' properties
		when the element is skipping its contents to avoid phantom sizes.
		(<a href="https://github.com/w3c/csswg-drafts/issues/6308">Issue 6308</a>).
	* Added logical property group for 'contain-intrinsic-size' properties.
		(<a href="https://github.com/w3c/csswg-drafts/issues/2822">Issue 2822</a>).
	* Changed syntax of 'contain-intrinsic-size' to allow for more flexible combinations of values.
		(<a href="https://github.com/w3c/csswg-drafts/issues/8407">Issue 8407</a>).
	* Added ''width/calc-size()'' to the 'width', 'height', 'min-width', 'min-height', 'max-width', and 'max-height' properties.
		(<a href="https://github.com/w3c/csswg-drafts/issues/6265">Issue 6265</a>).
	* Changed definition of [=stretch-fit sizing=].
		(<a href="https://github.com/w3c/csswg-drafts/issues/11044">Issue 11044</a>).
	* Disallowed negative lengths in 'contain-intrinsic-*' properties.
		(<a href="https://github.com/w3c/csswg-drafts/issues/11945">Issue 11945</a>).
	* Added [=responsively-sized iframes=] via 'contain-intrinsic-size/from-element' value.
		(<a href="https://github.com/w3c/csswg-drafts/issues/1771">Issue 1771</a>).
	* Clarified that Flexbox's [=stretch-fit sizing=] behavior is slightly different from ''align-self/stretch''.
		(<a href="https://github.com/w3c/csswg-drafts/issues/11784">Issue 11784</a>).
	* Added Web Platform Tests coverage.
	<!-- Changes until 15 February 2026 -->

<h3 class=no-num id="changes-2020-10">
Changes since 20 October 2020 Working Draft</h3>

	Significant changes since the <a href="https://www.w3.org/TR/2020/WD-css-sizing-4-20201020/">20 October 2020 Working Draft</a> include:

	* Drafted 'min-intrinsic-sizing' property,
		to better control the min-content contributions of scroll containers.
		(<a href="https://github.com/w3c/csswg-drafts/issues/1865">Issue 1865</a>,
		 <a href="https://github.com/w3c/csswg-drafts/issues/4585">Issue 4585</a>)
	* Added longhands to 'contain-intrinsic-size' for controlling each axis independently.
		(<a href="https://github.com/w3c/csswg-drafts/issues/5432">Issue 5432</a>)
	* Drafted ''contain-intrinsic-size/auto'' value to 'contain-intrinsic-size'
		to allow “remembering” the previously-calculated size.
		(<a href="https://github.com/w3c/csswg-drafts/issues/5668">Issue 5668</a>,
		 <a href="https://github.com/w3c/csswg-drafts/issues/5815">Issue 5815</a>)
	* Defined handling of degenerate ratios in 'aspect-ratio'.
		(<a href="https://github.com/w3c/csswg-drafts/issues/5557">Issue 5557</a>)
	* Defined how 'aspect-ratio' impacts a replaced element’s natural sizes.
		(<a href="https://github.com/w3c/csswg-drafts/issues/5306">Issue 5306</a>)
	* Fixed some errors in the [[#aspect-ratio-size-transfers]] section,
		aligning the behavior to not conflict with behavior defined by CSS2 / CSS Flex Layout / etc.
		(<a href="https://github.com/w3c/csswg-drafts/issues/6071">Issue 6071</a>)
	* Added ''contain-intrinsic-size: auto none'' syntax.

	Significant changes since the <a href="https://www.w3.org/TR/2020/WD-css-sizing-4-20200526/">26 May 2020 First Public Working Draft</a> include:

	* Define [=ratio-determining axis=] as a term.

	* Define that min/max sizing constraints are transferred across an aspect-ratio,
		(<a href="https://github.com/w3c/csswg-drafts/issues/5257">Issue 5257</a>)
		<blockquote>
			<p>Additionally, sizing constraints in either axis
			(the <var>origin</var> axis)
			are transferred through the [=preferred aspect ratio=]
			to the other axis (the <var>destination</var> axis)
			as follows:

			* First, any [=definite=] [=minimum size=] is converted and transferred
				from the <var>origin</var> to <var>destination</var> axis.
				This transferred minimum is capped
				by any [=definite=] [=preferred size|preferred=] or [=maximum size=]
				in the <var>destination</var> axis.
			* Then, any [=definite=] [=maximum size=] is converted and transferred
				from the <var>origin</var> to <var>destination</var>.
				This transferred maximum is floored
				by any [=definite=] [=preferred size|preferred=] or [=minimum size=]
				in the <var>destination</var> axis
				as well as by the transferred minimum, if any.

			Note: The basic principle is that sizing constraints
			transfer through the aspect-ratio to the other side
			to preserve the aspect ratio to the extent that they can
			without violating any sizes specified explicitly on that affected axis.
			<!-- This is the principle that drove the contents of the table in CSS2 Section 10.4. -->
		</blockquote>

	* Clarify that 'aspect-ratio' on a [=replaced element=] with only one [=natural size=] determines the other dimension.
		(<a href="https://github.com/w3c/csswg-drafts/issues/5306">Issue 5306</a>)
		<blockquote>
			<p>If a replaced element's only natural dimension
			is a natural width or a natural height,
			giving it a [=preferred aspect ratio=]
			also gives it a natural height or width,
			whichever was missing,
			by transferring the existing size
			through the [=preferred aspect ratio=].
		</blockquote>

	* Define that 'aspect-ratio' inhibits margin self-collapsing
		(<a href="https://github.com/w3c/csswg-drafts/issues/5328">Issue 5328</a>)
		<blockquote>
			<p>For the purpose of margin collapsing ([[css2/box#collapsing-margins]]),
			if the [=block axis=] is the [=ratio-dependent axis=],
			it is not considered to have a [=computed value|computed=] 'block-size' of ''height/auto''.
		</blockquote>


<h3 class=no-num id="additions-L3">
Additions Since Level 3</h3>

	<ul>
		<li>Added ''stretch'', ''fit-content'', and ''contain'' keywords for sizing properties.
		<li>Added 'aspect-ratio' property.
		<li>Added 'contain-intrinsic-width', 'contain-intrinsic-height', 'contain-intrinsic-block-size', and 'contain-intrinsic-inline-size' properties
			and their shorthand 'contain-intrinsic-size'.
		<li>Added 'min-intrinsic-sizing' property.
	</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 Considerations</h2>

This specification introduces no new privacy considerations.

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

This specification introduces no new security considerations.

<wpt hidden="Tests that need to be moved to the appropriate sections once the Level 3 text got merged.">
	<!-- #available -->
	available-height-for-replaced-content-001.html
	table-percentage-max-width-beside-float.html
	table-percentage-min-width-below-float.html
	table-percentage-min-width-beside-float.html
	<!-- #preferred-aspect-ratio -->
	replaced-fractional-height-from-aspect-ratio.html
	<!-- #preferred-size-properties -->
	animation/height-composition.html
	animation/height-interpolation.html
	animation/height-no-interpolation.html
	animation/width-composition.html
	animation/width-interpolation.html
	percentage-height-replaced-content-in-auto-cb.html
	parsing/height-invalid.html
	parsing/height-valid.html
	parsing/width-invalid.html
	parsing/width-valid.html
	<!-- #min-size-properties -->
	animation/min-height-composition.html
	animation/min-height-interpolation.html
	animation/min-width-composition.html
	animation/min-width-interpolation.html
	button-min-width.html
	grid-item-image-percentage-min-height-computes-as-0.html
	parsing/min-height-computed.html
	parsing/min-height-invalid.html
	parsing/min-height-valid.html
	parsing/min-width-computed.html
	parsing/min-width-invalid.html
	parsing/min-width-valid.html
	<!-- #max-size-properties -->
	animation/max-height-composition.html
	animation/max-height-interpolation.html
	animation/max-width-composition.html
	animation/max-width-interpolation.html
	block-image-percentage-max-height-inside-inline.html
	image-percentage-max-height-in-anonymous-block.html
	nested-flexbox-image-percentage-max-height-computes-as-none.html
	parsing/max-height-computed.html
	parsing/max-height-invalid.html
	parsing/max-height-valid.html
	parsing/max-width-computed.html
	parsing/max-width-invalid.html
	parsing/max-width-valid.html
	<!-- #valdef-width-length-percentage-0 -->
	thin-element-render.html
	<!-- #valdef-width-min-content -->
	clone-intrinsic-size.html
	clone-nowrap-intrinsic-size-bidi.html
	clone-nowrap-intrinsic-size.html
	min-content-negative-margin-crash.html
	replaced-max-height-min-content.html
	replaced-max-size-saturation.html
	replaced-max-width-min-content.html
	replaced-min-height-min-content.html
	replaced-min-width-min-content.html
	shrink-to-fit-sizing-max-width-min-content.html
	slice-intrinsic-size.html
	slice-nowrap-intrinsic-size-bidi.html
	slice-nowrap-intrinsic-size.html
	svg-no-ar-max-height-min-content.html
	svg-no-ar-min-height-min-content.html
	<!-- #funcdef-width-fit-content -->
	auto-scrollbar-inside-stf-abspos.html
	block-fit-content-as-initial.html
	fit-content-length-percentage-001.html
	fit-content-length-percentage-002.html
	fit-content-length-percentage-003.html
	fit-content-length-percentage-004.html
	fit-content-length-percentage-005.html
	fit-content-length-percentage-006.html
	fit-content-length-percentage-007.html
	fit-content-length-percentage-008.html
	fit-content-length-percentage-009.html
	fit-content-length-percentage-010.html
	fit-content-length-percentage-011.html
	fit-content-length-percentage-012.html
	fit-content-length-percentage-013.html
	fit-content-length-percentage-014.html
	fit-content-length-percentage-015.html
	fit-content-length-percentage-016.html
	<!-- #sizing-values -->
	block-size-with-min-or-max-content-1a.html
	block-size-with-min-or-max-content-1b.html
	block-size-with-min-or-max-content-2.html
	block-size-with-min-or-max-content-3.html
	block-size-with-min-or-max-content-4.html
	block-size-with-min-or-max-content-5.html
	block-size-with-min-or-max-content-6.html
	block-size-with-min-or-max-content-7.html
	block-size-with-min-or-max-content-table-1a.html
	block-size-with-min-or-max-content-table-1b.html
	hori-block-size-small-or-larger-than-container-with-min-or-max-content-1.html
	hori-block-size-small-or-larger-than-container-with-min-or-max-content-2a.html
	hori-block-size-small-or-larger-than-container-with-min-or-max-content-2b.html
	image-min-max-content-intrinsic-size-change-001.html
	image-min-max-content-intrinsic-size-change-002.html
	image-min-max-content-intrinsic-size-change-003.html
	image-min-max-content-intrinsic-size-change-004.html
	image-min-max-content-intrinsic-size-change-005.html
	image-min-max-content-intrinsic-size-change-006.html
	image-min-max-content-intrinsic-size-change-007.html
	image-min-max-content-intrinsic-size-change-008.html
	keyword-sizes-for-intrinsic-contributions.html
	keyword-sizes-for-intrinsic-contributions-002.html
	keyword-sizes-on-abspos.html
	keyword-sizes-on-flex-item-001.html
	keyword-sizes-on-flex-item-002.html
	keyword-sizes-on-floated-element.html
	keyword-sizes-on-inline-block.html
	keyword-sizes-on-replaced-element.html
	min-content-min-width-000.html
	percentage-min-width.html
	vert-block-size-small-or-larger-than-container-with-min-or-max-content-1.html
	vert-block-size-small-or-larger-than-container-with-min-or-max-content-2a.html
	vert-block-size-small-or-larger-than-container-with-min-or-max-content-2b.html
	<!-- #behave-auto -->
	margin-collapse-with-indefinite-block-size-001.html
	margin-collapse-with-indefinite-block-size-002.html
	margin-collapse-with-indefinite-block-size-003.html
	margin-collapse-with-indefinite-block-size-004.html
	margin-collapse-with-indefinite-block-size-005.html
	<!-- #box-sizing -->
	box-sizing-replaced-001.xht
	box-sizing-replaced-002.xht
	box-sizing-replaced-003.xht
	parsing/box-sizing-computed.html
	parsing/box-sizing-invalid.html
	parsing/box-sizing-valid.html
	<!-- #valdef-box-sizing-content-box -->
	box-sizing-content-box-001.xht
	box-sizing-content-box-002.xht
	box-sizing-content-box-003.xht
	<!-- #valdef-box-sizing-border-box -->
	border-box-and-max-content-001.html
	border-box-and-max-content-002.html
	border-box-and-max-content-003.html
	box-sizing-border-box-001.xht
	box-sizing-border-box-002.xht
	box-sizing-border-box-003.xht
	box-sizing-border-box-004.xht
	table-child-percentage-height-with-border-box.html
	<!-- #percentage-sizing -->
	percentage-height-in-flexbox.html
	range-percent-intrinsic-size-1.html
	range-percent-intrinsic-size-2.html
	range-percent-intrinsic-size-2a.html
	<!-- #intrinsic -->
	canvas-intrinsic-dynamic.html
	intrinsic-percent-replaced-dynamic-001.html
	intrinsic-percent-replaced-dynamic-002.html
	intrinsic-percent-replaced-dynamic-003.html
	intrinsic-percent-replaced-dynamic-004.html
	intrinsic-percent-replaced-dynamic-005.html
	intrinsic-percent-replaced-dynamic-006.html
	intrinsic-percent-replaced-dynamic-007.html
	intrinsic-percent-replaced-dynamic-008.html
	intrinsic-percent-replaced-dynamic-009.html
	intrinsic-percent-replaced-dynamic-010.html
	intrinsic-percent-replaced-dynamic-011.html
	intrinsic-percent-replaced-dynamic-012.html
	intrinsic-ratio-replaced-box-sizing.html
	intrinsic-size-fallback-replaced.html
	<!-- #:~:text=300x150%20default%20size -->
	replaced-fractional-height-from-aspect-ratio-2.html
	<!-- #intrinsic-sizes -->
	aspect-ratio-affects-container-width-when-height-changes.html
	calc-margins-block.html
	calc-margins-fieldset-content.html
	calc-margins-fieldset-legend.html
	calc-margins-flex.html
	calc-margins-table-caption.html
	image-fractional-height-with-wide-aspect-ratio.html
	intrinsic-fixed-width-with-max-content-height.html
	intrinsic-fixed-width-with-min-content-height.html
	intrinsic-percent-replaced-001.html
	intrinsic-percent-replaced-002.html
	intrinsic-percent-replaced-003.html
	intrinsic-percent-replaced-004.html
	intrinsic-percent-replaced-005.html
	intrinsic-percent-replaced-006.html
	intrinsic-percent-replaced-007.html
	intrinsic-percent-replaced-008.html
	intrinsic-percent-replaced-009.html
	intrinsic-percent-replaced-010.html
	intrinsic-percent-replaced-011.html
	intrinsic-percent-replaced-012.html
	intrinsic-percent-replaced-013.html
	intrinsic-percent-replaced-014.html
	intrinsic-percent-replaced-015.html
	intrinsic-percent-replaced-016.html
	intrinsic-percent-replaced-017.html
	intrinsic-percent-replaced-018.html
	intrinsic-percent-replaced-019.html
	intrinsic-percent-replaced-020.html
	intrinsic-percent-replaced-021.html
	intrinsic-percent-replaced-022.html
	intrinsic-percent-replaced-023.html
	intrinsic-percent-replaced-024.html
	intrinsic-percent-replaced-025.html
	intrinsic-percent-replaced-026.html
	intrinsic-percent-replaced-027.html
	intrinsic-size-fallback-video.html
	max-content-input-001.html
	ortho-writing-mode-001.html
	orthogonal-writing-mode-float-in-inline.html
	replaced-aspect-ratio-intrinsic-size-001.html
	replaced-aspect-ratio-intrinsic-size-002.html
	replaced-aspect-ratio-stretch-fit-001.html
	replaced-aspect-ratio-stretch-fit-002.html
	replaced-aspect-ratio-stretch-fit-003.html
	svg-intrinsic-size-001.html
	svg-intrinsic-size-002.html
	svg-intrinsic-size-003.html
	svg-intrinsic-size-004.html
	svg-intrinsic-size-005.html
	svg-intrinsic-size-006.html
	whitespace-and-break.html
	<!-- #intrinsic-contribution -->
	intrinsic-percent-non-replaced-001.html
	intrinsic-percent-non-replaced-002.html
	intrinsic-percent-non-replaced-003.html
	intrinsic-percent-non-replaced-004.html
	intrinsic-percent-non-replaced-005.html
	<!-- #replaced-percentage-min-contribution -->
	intrinsic-percent-replaced-028.html
	<!-- #cyclic-percentage-contribution -->
	inline-intrinsic-size-calc.html
	intrinsic-percent-non-replaced-006.html
</wpt>

<wpt hidden title="Features from other specs">
	abspos-auto-sizing-fit-content-percentage-001.html
	abspos-auto-sizing-fit-content-percentage-002.html
	abspos-auto-sizing-fit-content-percentage-003.html
	abspos-auto-sizing-fit-content-percentage-004.html
	animation/box-sizing-no-interpolation.html
</wpt>
