CSS Reference ยท Box Model and Sizing
The contain-intrinsic-size property
Reference for the CSS contain-intrinsic-size property: the size an element pretends to have when size containment or content-visibility skips its content.
When an element has size containment, or content-visibility: auto is skipping its content, the browser treats it as empty, so its height can collapse to zero. The contain-intrinsic-size property supplies a placeholder size to use instead. It stops pages from jumping and keeps the scrollbar honest.
.card { content-visibility: auto; contain-intrinsic-size: auto 320px; }
Try it
The first box collapses to just its border, since contain: size makes it behave as if it were empty. The second keeps the 90px height from the placeholder size (the content then overflows visibly).
Syntax
contain-intrinsic-size: [ auto? [ none | <length> ] ]{1,2}
The property is a shorthand for contain-intrinsic-width and contain-intrinsic-height. One value sets both; two values set width then height.
- Initial value:
none - Applies to: elements with size containment
- Inherited: no
- Animatable: yes, as a length
- Computed value: as specified, with lengths made absolute
Values
| Value | Description |
|---|---|
none |
No placeholder size: the dimension is treated as zero. |
<length> |
A fixed placeholder size for that dimension. Must not be negative. |
auto <length> |
Remember the last rendered size of the element and use it as the placeholder. The length is used until the element has been rendered once. |
auto none |
Use the last remembered size, or zero if there is none yet. |
Usage notes
- The usual pairing. Use
contain-intrinsic-size: auto 500pxtogether withcontent-visibility: auto. The first render uses 500px, and later the real measured height is remembered. - It is only an estimate. The placeholder does not size the element when its content is rendered; the real content decides then. A good estimate reduces scrollbar jumps; a poor one makes them noticeable.
- Per-axis control. For a block that only needs a placeholder height,
contain-intrinsic-block-size(logical form) orcontain-intrinsic-heightavoids touching the width. - No effect without containment. It does nothing on an element that lacks size containment or skipped content.
Browser support
Supported in current versions of Chromium-based browsers, Firefox and Safari, so it is part of Baseline. The auto keyword arrived later than the basic form, so check the support tables if you rely on it in older browsers.