CSS contain-intrinsic-height Property

The contain-intrinsic-height property specifies a fallback intrinsic height for an element when size containment prevents its contents from contributing to its intrinsic height.

Unlike the logical contain-intrinsic-block-size property, contain-intrinsic-height always refers to the physical height dimension, regardless of the element's writing mode.

This property is particularly useful with content-visibility: auto, where an estimated height can help reserve space while the browser skips rendering an element's contents.

contain-intrinsic-height Syntax

The contain-intrinsic-height property accepts a nonnegative length, none, or auto followed by a length or none.

selector {
  contain-intrinsic-height: 300px;
}

General Syntax

selector {
  contain-intrinsic-height: auto? [ none | <length> ];
}

Length Value

.component {
  contain-intrinsic-height: 300px;
}

Relative Length

.component {
  contain-intrinsic-height: 20rem;
}

Automatic Remembered Height

.component {
  contain-intrinsic-height: auto 300px;
}

Automatic with No Fallback

.component {
  contain-intrinsic-height: auto none;
}

No Intrinsic Height Fallback

.component {
  contain-intrinsic-height: none;
}

Zero Length

.component {
  contain-intrinsic-height: 0;
}

CSS-Wide Keywords

.component {
  contain-intrinsic-height: inherit;
}
.component {
  contain-intrinsic-height: initial;
}
.component {
  contain-intrinsic-height: unset;
}
.component {
  contain-intrinsic-height: revert;
}
.component {
  contain-intrinsic-height: revert-layer;
}

The auto keyword cannot appear alone. It must be followed by a valid nonnegative length or none.

Property Values

The property supports the following values:

Value Description
none Provides no specified fallback intrinsic height. This is the initial value.
300px Uses 300 pixels as the fallback intrinsic height when applicable.
20rem Uses a fallback intrinsic height relative to the root font size.
15em Uses a fallback intrinsic height relative to the element's font size.
0 Specifies a zero-length intrinsic height fallback.
auto 300px Uses a remembered intrinsic height when available, otherwise 300 pixels.
auto none Uses a remembered intrinsic height when available, otherwise no specified fallback.

CSS-Wide Keywords

Value Description
inherit Uses the computed value of the parent element.
initial Resets the property to none.
unset Resets the property to none because it is not inherited.
revert Reverts the property according to cascade origin rules.
revert-layer Reverts the property according to cascade layer rules.

Property Characteristics

Characteristic Value
Initial value none
Inherited No
Applies to Elements for which size containment can apply
Computed value Specified keyword and computed length, when present
Animation type By computed value type
Percentages Not accepted
Negative lengths Not accepted
Dimension Physical height

The property supplies an intrinsic sizing fallback rather than directly assigning the element's used height.

How It Works

Size containment prevents an element's descendants from contributing to its intrinsic dimensions. The contain-intrinsic-height property provides a substitute intrinsic height when the relevant containment applies.

Step 1: Create a Component

<section class="component">
  <h3>CSS Reference</h3>
  <p>Explore CSS properties and examples.</p>
</section>

Step 2: Apply Size Containment

.component {
  contain: size;
}

The element's descendants no longer contribute to its intrinsic size in either physical dimension.

Step 3: Provide a Fallback Height

.component {
  contain: size;
  contain-intrinsic-height: 250px;
}

The browser can use 250 pixels as the element's intrinsic height contribution while height-related size containment is active.

Step 4: Establish the Width

.component {
  width: 100%;
  contain: size;
  contain-intrinsic-height: 250px;
}

In a horizontal writing mode, the specified width establishes the inline dimension, while the intrinsic height fallback helps determine the block dimension.

Step 5: Compare Normal Sizing

.component {
  contain: none;
  contain-intrinsic-height: 250px;
}

Without relevant size containment, the fallback does not replace normal intrinsic height calculations.

Important Distinction

The property does not behave like a fixed height declaration. It supplies a fallback used during intrinsic sizing, while other CSS sizing constraints still apply.

Length Values

The property accepts nonnegative CSS length values, including absolute and relative units.

Pixels

.component {
  contain-intrinsic-height: 300px;
}

rem Units

.component {
  contain-intrinsic-height: 20rem;
}

em Units

.component {
  contain-intrinsic-height: 18em;
}

Viewport Height

.component {
  contain-intrinsic-height: 30vh;
}

Dynamic Viewport Height

.component {
  contain-intrinsic-height: 30dvh;
}

Zero Length

.component {
  contain-intrinsic-height: 0;
}

Invalid Negative Length

.component {
  contain-intrinsic-height: -100px;
}

Negative lengths are invalid.

Invalid Percentage

.component {
  contain-intrinsic-height: 50%;
}

Percentage values are not accepted.

Practical Consideration

Choose a fallback length that approximates the expected content height. An inaccurate estimate can cause layout movement when the browser renders the actual contents.

The auto Keyword

The auto keyword allows the browser to use a remembered intrinsic height when one is available.

Valid Syntax

.component {
  contain-intrinsic-height: auto 300px;
}

Remembered Height

When the browser has a remembered intrinsic height for the element, it can use that value instead of the supplied fallback.

Fallback Height

If no remembered height is available, the browser uses the length specified after auto.

auto none

.component {
  contain-intrinsic-height: auto none;
}

This form uses a remembered intrinsic height when available and otherwise provides no specified fallback height.

Invalid Standalone auto

.component {
  contain-intrinsic-height: auto;
}

The standalone auto keyword is invalid.

When to Use

Use auto with a fallback length when an element may be rendered, skipped, and rendered again, allowing the browser to reuse a more accurate remembered height.

Remembered Intrinsic Height

The remembered-size feature helps the browser preserve a more accurate intrinsic height after the element has been rendered normally.

Initial Estimate

.article-section {
  content-visibility: auto;
  contain-intrinsic-height: auto 400px;
}

Before a remembered height exists, the 400-pixel fallback is available while the browser skips rendering the contents.

Actual Rendering

When the browser renders the element without size containment, its actual intrinsic height can be determined.

Remembering the Height

The browser may retain that intrinsic height for subsequent periods when the element is size-contained.

Reusing the Height

When the browser skips rendering again, the remembered height can replace the original fallback estimate.

Content Changes

If the content changes after the height is remembered, the stored value may not immediately match the element's updated intrinsic height.

Browser Management

Remembered intrinsic sizes are managed by the browser. Authors cannot assume that a remembered height will always be available.

Practical Consideration

Provide a realistic fallback length even when using auto, because the browser may not yet have a remembered size.

none Value

The none value specifies that no fallback intrinsic height is provided.

.component {
  contain-intrinsic-height: none;
}

Initial Value

The initial value of the property is none.

With Size Containment

.component {
  contain: size;
  contain-intrinsic-height: none;
}

When size containment prevents descendants from contributing to intrinsic height and no fallback is supplied, the element may have no content-based intrinsic height contribution.

Difference from Zero

.component {
  contain-intrinsic-height: 0;
}

The value 0 explicitly supplies a zero-length fallback. The value none provides no specified fallback intrinsic height.

With auto

.component {
  contain-intrinsic-height: auto none;
}

This form uses a remembered intrinsic height when available, otherwise no specified fallback.

When to Use

Use none when no fallback is needed or when another sizing mechanism determines the element's dimensions.

Physical Height and Writing Modes

The contain-intrinsic-height property always refers to physical height, regardless of the writing mode.

Horizontal Writing Mode

.component {
  writing-mode: horizontal-tb;
  contain: size;
  contain-intrinsic-height: 250px;
}

In horizontal writing mode, physical height corresponds to the logical block dimension.

Vertical Writing Mode

.component {
  writing-mode: vertical-rl;
  contain: size;
  contain-intrinsic-height: 250px;
}

In vertical writing mode, physical height corresponds to the logical inline dimension.

Vertical Left-to-Right Writing

.component {
  writing-mode: vertical-lr;
  contain: size;
  contain-intrinsic-height: 250px;
}

Physical vs. Logical Dimensions

Writing Mode Physical Height Logical Block Size
horizontal-tb Block dimension Height
vertical-rl Inline dimension Width
vertical-lr Inline dimension Width

Logical Alternative

.component {
  contain-intrinsic-block-size: 250px;
}

The logical contain-intrinsic-block-size property follows the block dimension instead of always referring to physical height.

Practical Consideration

Use contain-intrinsic-height when the fallback must refer specifically to physical height. Use logical intrinsic sizing when the dimension should adapt to writing modes.

Working with Size Containment

The property supplies a fallback intrinsic height when size containment applies to the physical height dimension.

Full Size Containment

.component {
  contain: size;
  contain-intrinsic-height: 300px;
}

Strict Containment

.component {
  contain: strict;
  contain-intrinsic-height: 300px;
}

The strict keyword includes full size containment.

Size and Layout Containment

.component {
  contain: size layout;
  contain-intrinsic-height: 300px;
}

Size and Paint Containment

.component {
  contain: size paint;
  contain-intrinsic-height: 300px;
}

Inline-Size Containment

.component {
  writing-mode: horizontal-tb;
  contain: inline-size;
  contain-intrinsic-height: 300px;
}

In horizontal writing mode, inline-size containment affects width rather than height, so the height fallback does not replace normal intrinsic height sizing.

Vertical Writing Mode with Inline-Size Containment

.component {
  writing-mode: vertical-rl;
  contain: inline-size;
  contain-intrinsic-height: 300px;
}

In vertical writing mode, the inline dimension corresponds to physical height. The height fallback can therefore be relevant when inline-size containment applies.

Layout Containment Alone

.component {
  contain: layout;
  contain-intrinsic-height: 300px;
}

Layout containment alone does not prevent descendants from contributing to intrinsic height.

Content Containment

.component {
  contain: content;
  contain-intrinsic-height: 300px;
}

The content keyword does not include size containment, so normal intrinsic height sizing remains available.

Practical Consideration

Check which physical dimension is affected by the selected containment mode, especially when using vertical writing modes.

Working with content-visibility

The content-visibility property allows browsers to skip rendering work for suitable content. An intrinsic height fallback can help preserve space while rendering is skipped.

Basic Example

.article-section {
  content-visibility: auto;
  contain-intrinsic-height: 400px;
}

Remembered Height Example

.article-section {
  content-visibility: auto;
  contain-intrinsic-height: auto 400px;
}

Skipped Rendering

When the browser skips rendering an element's contents, size containment applies. The intrinsic height fallback can contribute to the element's sizing.

Rendered Content

When the browser renders the contents normally, the actual content can determine the element's intrinsic height.

Documentation Sections

.documentation-section {
  content-visibility: auto;
  contain-intrinsic-height: auto 500px;
}

Repeated Components

.reference-card {
  content-visibility: auto;
  contain-intrinsic-height: auto 250px;
}

Why the Fallback Matters

Without an appropriate fallback, skipped content may reserve less space than it needs when rendered, resulting in layout movement.

Practical Consideration

Use realistic estimates based on the expected rendered height of each component.

contain-intrinsic-height vs. height

The contain-intrinsic-height and height properties serve different purposes.

height

.component {
  height: 300px;
}

The height property directly participates in determining the element's used physical height.

contain-intrinsic-height

.component {
  contain: size;
  contain-intrinsic-height: 300px;
}

The contain-intrinsic-height property supplies an intrinsic height fallback when relevant size containment is active.

Key Differences

Property Purpose
height Specifies the element's physical height according to normal CSS sizing rules.
contain-intrinsic-height Supplies an intrinsic height fallback during applicable size containment.
min-height Establishes a minimum physical height.
max-height Establishes a maximum physical height.

Combined Example

.component {
  min-height: 200px;
  contain: size;
  contain-intrinsic-height: 300px;
}

The fallback contributes to intrinsic sizing, while the minimum height remains a separate constraint.

Practical Consideration

Use height when an element needs a specified physical height. Use contain-intrinsic-height when a size-contained element needs an intrinsic height fallback.

Layout Stability

Providing an estimated intrinsic height can reduce layout movement when previously skipped content becomes rendered.

Without a Fallback

.article-section {
  content-visibility: auto;
}

When rendering is skipped, the browser may have insufficient information to reserve space comparable to the eventual content height.

With a Fallback

.article-section {
  content-visibility: auto;
  contain-intrinsic-height: 400px;
}

With Remembered Height

.article-section {
  content-visibility: auto;
  contain-intrinsic-height: auto 400px;
}

Choosing an Estimate

Base the fallback on the component's typical rendered height rather than an arbitrary value.

Different Content Types

.summary-section {
  contain-intrinsic-height: auto 200px;
}
.reference-section {
  contain-intrinsic-height: auto 500px;
}
.example-section {
  contain-intrinsic-height: auto 350px;
}

Overestimated Height

An excessively large fallback can reserve unnecessary blank space while content is skipped.

Underestimated Height

An excessively small fallback can cause the page to expand noticeably when the content becomes rendered.

Practical Consideration

Test fallback estimates at different viewport widths and browser zoom levels. Accurate estimates can improve stability but do not guarantee that layout shifts will be eliminated.

CSS provides physical and logical intrinsic size fallback properties, along with a shorthand for the logical dimensions.

Property Purpose
contain-intrinsic-height Provides a fallback intrinsic physical height.
contain-intrinsic-width Provides a fallback intrinsic physical width.
contain-intrinsic-block-size Provides a fallback intrinsic logical block size.
contain-intrinsic-inline-size Provides a fallback intrinsic logical inline size.
contain-intrinsic-size Shorthand for logical inline-size and block-size fallbacks.

Physical Height

.component {
  contain-intrinsic-height: 300px;
}

Physical Width

.component {
  contain-intrinsic-width: 400px;
}

Logical Block Size

.component {
  contain-intrinsic-block-size: 300px;
}

Logical Inline Size

.component {
  contain-intrinsic-inline-size: 400px;
}

Shorthand

.component {
  contain-intrinsic-size: 400px 300px;
}

The first shorthand value specifies the logical inline-size fallback, and the second specifies the logical block-size fallback.

Remembered Sizes with the Shorthand

.component {
  contain-intrinsic-size: auto 400px auto 300px;
}

Practical Consideration

Choose physical properties when dimensions must correspond to physical width or height. Choose logical properties when the fallback should adapt to the element's writing mode.

Calculated Values and Variables

The fallback height can use CSS math functions and custom properties, provided the resulting value is a valid nonnegative length.

Using calc()

.component {
  contain-intrinsic-height: calc(200px + 5rem);
}

Using clamp()

.component {
  contain-intrinsic-height: clamp(200px, 30vh, 500px);
}

Using min()

.component {
  contain-intrinsic-height: min(400px, 50vh);
}

Using max()

.component {
  contain-intrinsic-height: max(250px, 20vh);
}

Using a Custom Property

:root {
  --section-height: 350px;
}
.component {
  contain-intrinsic-height: var(--section-height);
}

Custom Property with auto

.component {
  --fallback-height: 350px;
  contain-intrinsic-height: auto var(--fallback-height);
}

Component-Specific Fallbacks

.component {
  --fallback-height: 300px;
  contain-intrinsic-height: auto var(--fallback-height);
}
.component.large {
  --fallback-height: 600px;
}

Practical Consideration

CSS math functions and custom properties are useful when fallback heights should adapt to viewport dimensions or remain consistent across repeated components.

Responsive Layouts

Fallback intrinsic heights can be adjusted for different viewport or container sizes.

Basic Fallback

.article-section {
  content-visibility: auto;
  contain-intrinsic-height: auto 400px;
}

Tablet Layout

@media (max-width: 900px) {
  .article-section {
    contain-intrinsic-height: auto 500px;
  }
}

Mobile Layout

@media (max-width: 600px) {
  .article-section {
    contain-intrinsic-height: auto 650px;
  }
}

Narrower layouts may produce taller content because text wraps onto additional lines.

Using clamp()

.article-section {
  contain-intrinsic-height: auto clamp(300px, 40vh, 600px);
}

Container Queries

.section-wrapper {
  container-type: inline-size;
}
.article-section {
  contain-intrinsic-height: auto 350px;
}
@container (max-width: 500px) {
  .article-section {
    contain-intrinsic-height: auto 500px;
  }
}

Custom Property Approach

.article-section {
  --fallback-height: 400px;
  contain-intrinsic-height: auto var(--fallback-height);
}
@media (max-width: 600px) {
  .article-section {
    --fallback-height: 600px;
  }
}

Practical Consideration

Adjust fallback estimates only when the component's expected rendered height changes meaningfully between layouts.

Practical Uses

The contain-intrinsic-height property is useful when a component needs an estimated physical height while its contents are subject to size containment.

Long Documentation Pages

.documentation-section {
  content-visibility: auto;
  contain-intrinsic-height: auto 500px;
}

Reference Sections

.reference-section {
  content-visibility: auto;
  contain-intrinsic-height: auto 350px;
}

Code Example Panels

.code-example {
  content-visibility: auto;
  contain-intrinsic-height: auto 300px;
}

Repeated Content Cards

.content-card {
  content-visibility: auto;
  contain-intrinsic-height: auto 220px;
}

Article Sections

.article-section {
  content-visibility: auto;
  contain-intrinsic-height: auto 600px;
}

Size-Contained Panels

.preview-panel {
  contain: size;
  contain-intrinsic-height: 240px;
}

When Not to Use

The property is generally unnecessary for elements that are not subject to relevant size containment and can determine their intrinsic height normally.

Practical Consideration

Use fallback intrinsic heights where they improve layout stability or provide predictable sizing for contained components.

contain-intrinsic-height Example

The following example compares two size-contained elements. The first has no intrinsic height fallback, while the second supplies a 150-pixel fallback.

Both containers use contain: size, preventing their descendants from contributing to intrinsic sizing.

<div class="intrinsic-height-demo">
  <div class="intrinsic-example">
    <h3>Without a Fallback</h3>
    <div class="intrinsic-box no-fallback">
      <p>This content does not determine the container's intrinsic height.</p>
    </div>
  </div>
  <div class="intrinsic-example">
    <h3>With a 150px Fallback</h3>
    <div class="intrinsic-box with-fallback">
      <p>This container uses a fallback intrinsic height of 150 pixels.</p>
    </div>
  </div>
</div>
.intrinsic-height-demo {
  display: grid;
  gap: 20px;
}
.intrinsic-height-demo .intrinsic-example {
  padding: 15px;
  border: 1px solid #cccccc;
  background-color: #f8f9fa;
}
.intrinsic-height-demo h3 {
  margin: 0 0 12px;
  font-size: 1.125rem;
}
.intrinsic-height-demo .intrinsic-box {
  contain: size;
  display: flow-root;
  box-sizing: border-box;
  padding: 15px;
  border: 2px solid #336699;
  background-color: #ffffff;
}
.intrinsic-height-demo .intrinsic-box p {
  margin: 0;
}
.intrinsic-height-demo .no-fallback {
  contain-intrinsic-height: none;
}
.intrinsic-height-demo .with-fallback {
  contain-intrinsic-height: 150px;
}
Browser Result

Without a Fallback

This content does not determine the container's intrinsic height.

With a 150px Fallback

This container uses a fallback intrinsic height of 150 pixels.

The first container has no fallback intrinsic height. Because contain: size prevents its contents from contributing to intrinsic sizing, its height is determined by padding, borders, and other applicable sizing constraints.

The second container uses contain-intrinsic-height: 150px, supplying a 150-pixel intrinsic height contribution. Padding and borders are added according to the box model.

This demonstrates that contain-intrinsic-height provides a fallback intrinsic height rather than directly setting the element's used height.

Accessibility

Intrinsic height fallbacks can influence the space reserved for content, so appropriate estimates are important for accessible layouts.

Avoid Content Overlap

Choose fallback heights that provide sufficient space for the component's expected contents when size containment applies.

Support Text Resizing

Test with enlarged text and increased browser zoom. Content may require more vertical space than the original estimate.

Reduce Layout Movement

Realistic fallback heights can reduce unexpected movement when skipped content becomes rendered.

Preserve Reading Order

The property does not change the HTML source order or semantic document structure.

Test Keyboard Navigation

When combined with content-visibility, verify that interactive elements remain accessible and usable as content becomes rendered.

Avoid Unnecessary Fixed Heights

Intrinsic height fallbacks can allow content to determine its actual height when rendered, unlike rigid fixed-height layouts.

Practical Consideration

Test realistic content, different font sizes, and narrow viewports to ensure fallback sizing does not interfere with readability or interaction.

Important Considerations

Keep the following points in mind when using contain-intrinsic-height:

  • Purpose: Provides a fallback intrinsic physical height when relevant size containment applies.
  • Initial value: none.
  • Inheritance: The property is not inherited.
  • Dimension: Always refers to physical height.
  • Writing modes: Physical height may correspond to the logical block or inline dimension.
  • Length values: Accepts nonnegative CSS lengths.
  • Percentages: Not accepted.
  • Negative values: Not accepted.
  • none: Provides no specified fallback intrinsic height.
  • auto: Must be followed by a length or none.
  • auto with length: Uses a remembered intrinsic height when available, otherwise the supplied fallback.
  • auto none: Uses a remembered intrinsic height when available, otherwise no specified fallback.
  • Size containment: The fallback is relevant when containment affects the physical height dimension.
  • Inline-size containment: Can affect physical height in vertical writing modes.
  • Layout containment: Does not activate the intrinsic height fallback by itself.
  • content containment: Does not include size containment.
  • strict containment: Includes full size containment.
  • content-visibility: Commonly used with this property to reserve space during skipped rendering.
  • Remembered sizes: Managed by the browser and not guaranteed to be available.
  • Used height: The property supplies an intrinsic sizing contribution rather than an enforced physical height.
  • Box model: Padding and borders remain part of the element's final dimensions.
  • Calculated values: CSS math functions can supply valid nonnegative lengths.
  • Custom properties: Can store reusable fallback height values.
  • Responsive layouts: Fallback estimates can change with media queries or container queries.
  • Layout stability: Accurate estimates can reduce movement when skipped content becomes rendered.
  • Accessibility: Test text resizing, browser zoom, and interactive content.

Use contain-intrinsic-height when an element needs a predictable intrinsic physical height during size containment. For content rendered normally without relevant size containment, the property generally has no visible effect.

Browser Support

The contain-intrinsic-height property is supported in current versions of major browsers, including Chrome, Edge, Firefox, and Safari.

Support for the auto remembered-size syntax and related containment features may vary in older browser versions.

Basic Example

.component {
  contain: size;
  contain-intrinsic-height: 300px;
}

With content-visibility

.component {
  content-visibility: auto;
  contain-intrinsic-height: auto 300px;
}

Feature Detection

@supports (contain-intrinsic-height: auto 300px) {
  .component {
    content-visibility: auto;
    contain-intrinsic-height: auto 300px;
  }
}

Feature queries can determine whether a browser accepts the specified syntax, but they do not guarantee identical rendering behavior across browsers.

For current compatibility information, visit Can I Use? and search for contain-intrinsic-height.

Specifications

The contain-intrinsic-height property is defined in CSS Containment Module Level 3.

CSS Containment Module Level 3

The specification defines physical and logical intrinsic size fallback properties, length values, and remembered-size behavior associated with the auto keyword.