Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

contain-intrinsic-size — substitute intrinsic size

contain-intrinsic-size supplies a substitute content size under size containment. It preserves space even when layout does not determine the element’s size from its descendants.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

contain-intrinsic-size: [ auto? [ none | <length [0,∞]> ] ]{1,2};

contain-intrinsic-size is shorthand for contain-intrinsic-width and contain-intrinsic-height: width first, then height, regardless of writing mode. One value group applies to both dimensions. Lengths must be nonnegative; percentages are invalid.

none supplies no substitute size and is not equivalent to 0px. auto 300px uses the last remembered size when available and contents are being skipped; otherwise it uses 300px. Bare auto is invalid — it requires a length or none.

The property does not itself enable size containment. The example uses contain: size so sizing does not depend on descendants. Do not treat it as forced width and height: layout constraints still apply. Size containment does not automatically hide or clip content, so content can overflow the element.

Examples

<!doctype html>
<meta charset="utf-8">
<title>contain-intrinsic-size</title>
<style>
  #box {
    display: inline-block;
    contain: size;
    contain-intrinsic-size: 240px 120px;
    padding: 0;
    border: 0;
    background: lightblue;
  }
</style>
<div id="box"></div>
<pre id="result"></pre>
<script>
  const box = document.getElementById('box');
  const rect = box.getBoundingClientRect();
  document.getElementById('result').textContent =
    `${rect.width}px x ${rect.height}px`;
</script>

Result

240px x 120px

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources