CSS Portal

CSS contain-intrinsic-width Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The contain-intrinsic-width property provides a hint to the user agent about an element's intrinsic inline size (width) to be used when CSS containment prevents the browser from computing that size from the element’s normal contents. When an element is subject to containment, the rendering engine may not be allowed to inspect descendants to determine intrinsic dimensions; this property supplies a fallback intrinsic width so layout algorithms can proceed without expensive layout reads. It’s a tool for stabilizing layout decisions and avoiding layout jumps when content is hidden behind containment boundaries.

Because the value acts as an intrinsic-size hint rather than an absolute override, it is consulted by the browser during intrinsic sizing and min/max calculations. The hint is used by the algorithms that compute min-content, max-content and preferred sizes, which in turn affect how an element participates in flex, grid and block formatting contexts. This property is most useful where the UA needs an intrinsic inline size but containment or replaced content prevents deriving one directly; it works alongside containment behavior controlled by contain and should be thought of as part of the same containment/intrinsic-size toolset.

In practical terms, contain-intrinsic-width pairs naturally with vertical intrinsic hints such as contain-intrinsic-height and with aspect-ratio constraints like aspect-ratio. When an aspect ratio or the paired intrinsic height is present, the UA can reconcile the width hint with those constraints to produce consistent used sizes. Author-supplied intrinsic hints are particularly helpful for images, iframes or components rendered off-thread (or hydrated later) because they let you reduce content reflow without resorting to explicit sizing. If you already set explicit box sizes, the hint is simply an aid to intrinsic calculations and does not supersede explicit rules such as width or height, but it can significantly improve stability and performance when used appropriately.

Definition

Initial value
none
Applies to
elements for which size containment can apply
Inherited
no
Computed value
as specified, with lengths values computed
Animatable
by computed value type
JavaScript syntax
object.style.containIntrinsicWidth

Syntax

contain-intrinsic-width: auto? [ none | <length> ]

Values

  • auto? [ none | <length> ]If 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. Otherwise, the corresponding axis either doesn’t have an explicit intrinsic inner size (if none is specified) or has an explicit intrinsic inner size of the specified <length>.

Example

<div class='wrapper'>
<h1>contain-intrinsic-width demo</h1>
<div class='row'>
<div class='panel'>
<h2>With contain-intrinsic-width</h2>
<div class='card contained'>
<img src='https://picsum.photos/400/200' alt='sample'>
<h3>Card title</h3>
<p>Some longer description that would normally determine the element's width. This text will wrap to the intrinsic width declared on the element.</p>
</div>
</div>
<div class='panel'>
<h2>Without containment</h2>
<div class='card'>
<img src='https://picsum.photos/400/200' alt='sample'>
<h3>Card title</h3>
<p>Some longer description that would normally determine the element's width. Without containment the element sizes to its contents.</p>
</div>
</div>
</div>
</div>
.wrapper {
  max-width: 920px;
  margin: 40px auto;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  color: #222;
}

h1 {
  margin: 0 0 18px 0;
  font-size: 20px;
}

.row {
  display: flex;
  gap: 22px;
  align-items: flex-start;
}

.panel {
  background: #f8f9fa;
  padding: 14px;
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}

.panel h2 {
  margin: 0 0 12px 0;
  font-size: 14px;
}

.card {
  background: white;
  border: 1px solid #e6e9ee;
  padding: 10px;
  border-radius: 6px;
  box-sizing: border-box;
}

.card img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

.card h3 {
  margin: 10px 0 6px 0;
  font-size: 16px;
}

.card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.3;
}

/* The key part: apply containment and an intrinsic width */
.contained {
  contain: size;
  contain-intrinsic-width: 240px;
}

/* Visual hints to compare sizes */
.panel + .panel {
  margin-left: 0;
}

Browser Support

The following information will show you the current browser support for the CSS contain-intrinsic-width property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!