CKTIS / CSS
contain-intrinsic-width — substitute intrinsic width
contain-intrinsic-width supplies a substitute content width for size containment. It does not enable containment or replace the width property.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
contain-intrinsic-width: auto? [ none | <length [0,∞]> ];contain-intrinsic-width supplies a physical substitute width for intrinsic sizing. Initially none, it is not inherited. Lengths must be nonnegative; percentages are invalid.
none supplies no substitute size. auto 240px uses the last remembered size only when contents are skipped and a remembered size exists. Otherwise it uses 240px, including when contents are skipped but no size has been remembered yet. auto none is also valid, but standalone auto is not.
Size containment allows sizing without examining descendants. Enable it separately, for example with contain: size; contain: layout alone is insufficient. Containment does not remove content or itself guarantee clipping.
The example uses width: max-content to expose the substitute width. An ordinary block with width: auto can still fill its container. The expected measurement is 240px; local verification is required.
Examples
<!doctype html>
<meta charset="utf-8">
<title>contain-intrinsic-width</title>
<style>
#box {
contain: size;
contain-intrinsic-width: 240px;
width: max-content;
height: 40px;
padding: 0;
border: 0;
background: lightblue;
}
</style>
<div id="box"></div>
<pre id="result"></pre>
<script>
const box = document.getElementById('box');
document.getElementById('result').textContent =
`${box.getBoundingClientRect().width}px`;
</script>Result
240px
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.