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, Invited Expert, 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

Introduction

ISSUE: This is a diff spec over CSS Sizing Level 3. 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.

Module interactions

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]]

Value Definitions

This specification follows the CSS property definition conventions from [[!CSS2]] using the value definition syntax from [[!CSS-VALUES-3]]. Value types not defined in this specification are defined in CSS Values & 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 CSS-wide keywords as their property value. For readability they have not been repeated explicitly.

Terminology

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

Specifying Box Sizes

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

Sizing Properties

ISSUE(820): Add shorthands.

New Sizing Values: the ''stretch'', ''fit-content'', and ''contain'' keywords

	Name: 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
	New Values: stretch | fit-content | contain
	
stretch
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]].
fit-content
Essentially ''fit-content(stretch)'' i.e. min(''width/max-content'', max(''width/min-content'', ''width/stretch'')).
contain
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=].

Aspect Ratios

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 CSS2, Flex Layout, and Grid Layout specs combined (without this specification in effect), this is an error and should be reported to the CSSWG.

Preferred Aspect Ratios: the 'aspect-ratio' property

	Name: aspect-ratio
	Value: auto || <>
	Initial: auto
	Inherited: no
	Applies to: all elements except inline boxes and internal ruby or table boxes
	Computed value: specified keyword or a pair of numbers
	Animation type: by computed value
	
This property sets a preferred aspect ratio for the box, which will be used in the calculation of ''height/auto'' sizes and some other layout functions.
auto
Replaced elements with a natural aspect ratio use that aspect ratio; otherwise the box has no preferred aspect ratio. Size calculations involving the aspect ratio work with the content box dimensions always.
<>
The box’s preferred aspect ratio is the specified ratio of ''width / height''. Size calculations involving the aspect ratio work with the dimensions of the box specified by 'box-sizing'. If the <> is [=degenerate ratio|degenerate=], the property instead behaves as ''aspect-ratio/auto''.
auto && <>
If both ''auto'' and a <> are specified together, the [=preferred aspect ratio=] is the specified ratio of ''width / height'' 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 <> is [=degenerate ratio|degenerate=], the property instead behaves as ''aspect-ratio/auto''.
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.
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. <ul> <li>… <li>… <li>… <li>… </ul>
			ul {
				display: grid;
				grid-template-columns: repeat(auto-fill, minmax(12em, 1fr));
			}
			li {
				aspect-ratio: 1/1;
				overflow: auto;
			}
		
This example uses the <{iframe}> element’s width and height 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.
			<iframe
			  src="https://www.youtube.com/embed/0Gr1XSyxZy0"
			  width=560
			  height=315>
		
			@supports (aspect-ratio: attr(width number) / 1) {
			  iframe {
			    aspect-ratio: attr(width number) / attr(height number);
			    width: 100%;
			    height: auto;
			  }
			}
		
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=].

Effects of Preferred Aspect Ratio on Automatic Sizes

When a box has a [=preferred aspect ratio=], its automatic sizes are calculated the same as for a [=replaced element=] with a [=natural aspect ratio=] and no [=natural size=] in that axis, see e.g. CSS2 § 10 and CSS Flexible Box Model Level 1 § 9.2. The axis in which the preferred size calculation depends on this aspect ratio is called the ratio-dependent axis, and the resulting size is definite if its input sizes are also definite. The opposite axis (on which the [=ratio-dependent axis=] size depends) is the ratio-determining axis. 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.

Margin-collapsing

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

Automatic Content-based Minimum Sizes

In order to avoid unintentional overflow, the automatic minimum size in the ratio-dependent axis of a box with a preferred aspect ratio that is neither a replaced element nor a scroll container is its min-content size capped by its maximum size.
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.
		  div {
		    aspect-ratio: 1/1;
		    /* 'width' and 'height' both default to 'auto' */
		  }
		
		+----------+  +----------+  +----------+
		| ~~~~~~~~ |  | ~~~~~~~~ |  | ~~~~~~~~ |
		| ~~~~~~~~ |  | ~~~~~~~~ |  | ~~~~~~~~ |
		| ~~~~~~~  |  | ~~~~~~~~ |  | ~~~~~~~~ |
		|          |  | ~~~      |  | ~~~~~~~~ |
		+----------+  +----------+  | ~~~~~~~~ |
		                            | ~~~~~~   |
		                            +----------+
		
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).
		  div {
		    overflow: auto;
		    aspect-ratio: 1/1;
		  }
		
		+----------+  +----------+  +----------+
		| ~~~~~~~~ |  | ~~~~~~~~ |  | ~~~~~~~~^|
		| ~~~~~~~~ |  | ~~~~~~~~ |  | ~~~~~~~~ |
		| ~~~~~~~  |  | ~~~~~~~~ |  | ~~~~~~~~ |
		|          |  | ~~~      |  | ~~~~~~~~v|
		+----------+  +----------+  +----------+
		
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.
		  div {
		    aspect-ratio: 1/1;
		    min-height: 0;
		  }
		
		+----------+  +----------+  +----------+
		| ~~~~~~~~ |  | ~~~~~~~~ |  | ~~~~~~~~ |
		| ~~~~~~~~ |  | ~~~~~~~~ |  | ~~~~~~~~ |
		| ~~~~~~~  |  | ~~~~~~~~ |  | ~~~~~~~~ |
		|          |  | ~~~      |  | ~~~~~~~~ |
		+----------+  +----------+  +-~~~~~~~~-+
		                              ~~~~~~    
		
This automatic minimum operates in both axes. Consider this example:
			<div style="height: 100px; aspect-ratio: 1/1;">
				<span style="display: inline-block; width: 50px;"></span>
				<span style="display: inline-block; width: 150px;"></span>
			</div>
		
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.

Min/Max Size Transfers

Sizing constraints in either axis (the origin 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 destination axis) as follows: * First, any [=definite=] [=minimum size=] is converted and transferred from the origin to destination axis. This transferred minimum is capped by any [=definite=] [=preferred size|preferred=] or [=maximum size=] in the destination axis. * Then, any [=definite=] [=maximum size=] is converted and transferred from the origin to destination. This transferred maximum is floored by any [=definite=] [=preferred size|preferred=] or [=minimum size=] in the destination 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 constraint table in CSS2 Section 10.4.)
In the following example:
			<div id=container style="height: 100px; float: left;">
				<div id=item style="height: 100%; aspect-ratio: 1/1;">content</div>
			</div>
		
Since the height of the #item 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.
			<div id=container style="height: auto; float: left;">
				<div id=item style="height: 100%; aspect-ratio: 1/1;">content</div>
			</div>
		
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”.
ISSUE(6071): This section might not be written correctly.

Intrinsic Size Determination

Intrinsic Sizes

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

Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-*' properties

	Name: contain-intrinsic-width, contain-intrinsic-height, contain-intrinsic-block-size, contain-intrinsic-inline-size
	Value: none | <> | auto <>
	Initial: none
	Inherited: no
	Applies to: elements with [=size containment=]
	Computed value: as specified, with <> values computed
	Percentages: n/a
	Animation type: by computed value type
	
These properties allow elements with [=size containment=] to specify an explicit intrinsic inner size, 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. Values are defined as:
: none :: The corresponding axis does not have an [=explicit intrinsic inner size=]. : <> :: The corresponding axis has an [=explicit intrinsic inner size=] of the specified <>. : auto <> :: If the element has a [=last remembered size=] and is currently [=skipping its contents=], its [=explicit intrinsic inner size=] is the [=last remembered size=]. Note: This occurs, for example, when an element with ''content-visibility: auto'' is off-screen. Otherwise, its [=explicit intrinsic inner size=] is the specified <>.
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.
	Name: contain-intrinsic-size
	Value: [ none | <> | auto <> ]{1,2}
	
'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.

Last Remembered Size

[=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'' value allows a middle-ground: if an element is ever not [=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 probably sizing accurately to its contents. Only elements capable of being {{ResizeObserver}} targets can have a [=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 ''contain-intrinsic-size: auto'', 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 not have ''contain-intrinsic-size: auto'', remove its [=last remembered size=]. Note: The [=last remembered size=] is state attached to the element, not any particular box generated by the element. So long as the element retains ''contain-intrinsic-size: auto'', it will remember its [=last remembered size=] even across changes such as going to/from ''display: none''.

Interaction With ''overflow: auto''

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 sized as if it generated those scrollbar(s) in accordance with such hypothetical content.
In the following example code:
		div {
			width: max-content;
			contain-intrinsic-size: 100px 100px;
			overflow: auto;
		}
		
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.
In contrast, in the following example code:
		div {
			width: max-content;
			contain-intrinsic-size: 100px 100px;
			height: 50px;
			overflow: auto;
		}
		
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.

Intrinsic Size Contributions

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

Zeroing Min-Content Size Contributions: the 'min-intrinsic-sizing' property

	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
	
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:
legacy
The box’s [=min-content contribution=] is handled as normal.
zero-if-scroll
The box’s [=min-content contribution=] is “compressed” if it is a [=scroll container=].
zero-if-extrinsic
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=].
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):
*, ::before, ::after { min-intrinsic-size: zero-if-scroll; }
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.
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=].

Extrinsic Size Determination

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

Stretch-fit Sizing: filling the containing block

Stretch-fit sizing tries to set the box’s used size to the length necessary to make its 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. Formally, its behavior is the same as specifying an [=automatic size=] together with a [=self-alignment property=] value of ''width/stretch'' (in the relevant axis), except that the resulting box, which can end up not exactly fitting its [=alignment container=], can be subsequently aligned by its actual [=self-alignment property=] value. Additionally, in [=formatting contexts=] and axes in which the relevant [=self-alignment property=] does not apply (such as the block axis in Block Layout, or the main axis in Flex Layout), in cases where a percentage size in that axis would resolve to a definite value, a [=stretch-fit size=] causes the box to attempt to fill its containing block-- behaving as ''100%'' but applying the resulting size to its margin box instead of the box indicated by 'box-sizing'. For this purpose, ''margin/auto'' margins are treated as zero, and furthermore, for [=block-level boxes=] in particular, if its block-start/block-end [=margin=] would be adjoining to its parent's block-start/block-end [=margin=] if its parent’s [=sizing properties=] all had their [=initial values=], then its block-start/block-end [=margin=] is treated as zero. Note: Consequently, if neither ''align-self/stretch'' alignment applies nor percentage sizing can resolve, then the box will resolve to its [=automatic size=].
For example, given the following HTML representing two [=block boxes=]:
		  <div class="outer">
		    <div class="inner"></div>
		  </div>
		
In the following case, the [=outer height=] of the inner box will exactly match the height of the outer box (200px), but its [=inner height=] will be 20px less, to account for its margins.
		  .outer { height: 200px; border: solid; }
		  .inner { height: stretch; margin: 10px; }
		
In the following case, the height of the inner box will exactly match the height of the outer box (200px). The top margins will 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]]), and therefore the inner box’s bottom margin will be truncated.
		  .outer { height: 200px; margin: 0; }
		  .inner { height: stretch; margin: 10px; }
		
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):
		  <div class="outer">
		    <div class="inner">text</div>
		  </div>
		  some more text
		
			.outer { float: left; margin: 0; }
			.inner { width: stretch; margin: 10px; }
		
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.
		  .outer { height: auto; margin: 0; }
		  .inner { height: stretch; margin: 10px; }
		

Contain-fit Sizing: stretching while maintaining an aspect ratio

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:
  1. 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 stretch-fit sized.
  2. 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 box-sizing rules, this “maximum size” is floored by the effects of the box’s 'min-width'/'min-height'.)
  3. Last, the target rectangle is reduced in one dimension by the minimum necessary for it to match the box's [=preferred aspect ratio=].
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.

Percentage Sizing

Changes

Recent Changes

Significant changes since the 20 October 2020 Working Draft include: * Drafted 'min-intrinsic-sizing' property, to better control the min-content contributions of scroll containers. (Issue 1865, Issue 4585) * Added longhands to 'contain-intrinsic-size' for controlling each axis independently. (Issue 5432) * Drafted ''contain-intrinsic-size/auto'' value to 'contain-intrinsic-size' to allow “remembering” the previously-calculated size. (Issue 5668, Issue 5815) * Defined handling of degenerate ratios in 'aspect-ratio'. (Issue 5557) * Defined how 'aspect-ratio' impacts a replaced element’s natural sizes. (Issue 5306) * 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. (Issue 6071) Significant changes since the 26 May 2020 First Public Working Draft include: * Define [=ratio-determining axis=] as a term. * Define that min/max sizing constraints are transferred across an aspect-ratio, (Issue 5257)

Additionally, sizing constraints in either axis (the origin axis) are transferred through the [=preferred aspect ratio=] to the other axis (the destination axis) as follows: * First, any [=definite=] [=minimum size=] is converted and transferred from the origin to destination axis. This transferred minimum is capped by any [=definite=] [=preferred size|preferred=] or [=maximum size=] in the destination axis. * Then, any [=definite=] [=maximum size=] is converted and transferred from the origin to destination. This transferred maximum is floored by any [=definite=] [=preferred size|preferred=] or [=minimum size=] in the destination 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.

* Clarify that 'aspect-ratio' on a [=replaced element=] with only one [=natural size=] determines the other dimension. (Issue 5306)

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=].

* Define that 'aspect-ratio' inhibits margin self-collapsing (Issue 5328)

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

Additions Since Level 3

Acknowledgments

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

Privacy Considerations

This specification introduces no new privacy considerations.

Security Considerations

This specification introduces no new security considerations.