Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

How to Animate Height Changes with CSS Transitions

Use interpolate-size: allow-keywords to transition a panel between a fixed height and its natural auto height in supported browsers. Learn the limits, fallbacks, and layout trade-offs.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To transition an element between a fixed height and its natural auto height, opt into intrinsic-size interpolation with interpolate-size: allow-keywords, then transition height. This is the simplest CSS-first approach in browsers that support it; it is not yet a dependable universal solution, so check compatibility for your audience and plan a fallback.

Transition height from 0 to auto

Set the closed state to a length, hide overflow while it is collapsed, and set the open state to auto. The browser can interpolate between the length and the intrinsic size when interpolate-size is enabled:

.panel {
  height: 0;
  overflow: hidden;
  interpolate-size: allow-keywords;
  transition: height 250ms ease;
}

.panel.is-open {
  height: auto;
}

Your application must toggle .is-open or otherwise change the element between those states. The 250ms duration and easing are examples; adjust them to suit the interface. The open height follows the content rather than a guessed maximum.

Example disclosure markup

A button can toggle the panel class and expose its state to assistive technology. This example shows the markup and CSS; the state toggle itself must be supplied by your application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
<button type="button" aria-expanded="false" aria-controls="details">
  Show details
</button>
<div id="details" class="panel">
  <p>Content with a natural height determined by its contents.</p>
</div>

When the control opens the panel, update aria-expanded to true and apply is-open; reverse both changes when it closes. A production implementation should also ensure the panel’s hidden content cannot receive focus while the panel is closed.

What interpolate-size enables—and what it does not

MDN Web Docs describes interpolate-size: allow-keywords as enabling interpolation between a <length-percentage> value and an intrinsic-size value. That is what makes the length-to-auto pattern possible. It does not make transitions between two different intrinsic keywords interpolable.

The property is inherited. Put it on the component, or on an ancestor only if you deliberately want descendants to inherit the opt-in. Keeping it scoped avoids changing interpolation behavior more broadly than intended.

Browser support

MDN classifies interpolate-size as having limited availability and not Baseline. Check its current compatibility information against the actual browsers and versions your users need; do not assume support is equivalent across browsers. Chrome for Developers describes the opt-in and documents Chrome 130 support for intrinsic sizing keywords including auto; that Chrome-specific information does not establish support in other browsers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For browsers without the feature, a transition from a length to auto may not animate as intended. Decide on a fallback appropriate to your component rather than relying on the native transition everywhere.

When calc-size() is useful

Use calc-size() when the target needs arithmetic based on an intrinsic size—for example, height: calc-size(auto, size + 2rem). It provides a way to calculate from the intrinsic size; ordinary calc() does not accept intrinsic keywords for this purpose. For a plain transition to auto, MDN generally prefers interpolate-size, so there is no need to add calc-size() without a calculation to perform.

Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

MDN also marks calc-size() as limited availability and not Baseline. Check compatibility before depending on it in a shipped interface.

Choose a fallback based on the component

There is no single fallback recipe that is right for every height animation. Base the choice on whether content height changes, whether surrounding content must move, and which browsers you support.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Measured pixel height: Application code can measure the content and animate between explicit lengths where native intrinsic interpolation is unavailable. Re-measure when content changes or the available width changes, and handle interrupted open/close transitions.
  • Different visual reveal: If neighboring content does not need to move, a reveal effect that does not animate the box-model height may fit better. Check that the visual result and interaction behavior still meet the component’s needs.
  • Native intrinsic interpolation: Use the CSS pattern above when the target browsers support it and the open size should naturally follow the content.

Test content changes, viewport resizing, and a user reversing the transition before it finishes. Those cases expose brittle measurements and state handling that a static demo may not reveal.

Performance and layout trade-offs

Height is a box-model property, so animating it can require layout work as the element changes size. That cost can be justified when neighboring content needs to move with the panel. If the design can achieve the same result without changing the box size, MDN advises preferring a non-box-model property such as transform where practical. A transform-based effect does not make surrounding content flow into a newly expanded space, so it is not a like-for-like substitute for every disclosure.

Troubleshooting

  • The panel jumps instead of animating: Confirm that the browser supports interpolate-size, that the property is in effect on the transitioning element, and that the state changes from a length to an intrinsic keyword. Unsupported browsers need a fallback.
  • The panel opens but content is clipped: Check whether another rule constrains its height or overflow after opening. The closed-state overflow: hidden is useful for clipping during collapse, but make sure the open state is not unintentionally constrained by other styles.
  • The panel animates, but nearby content does not move: Confirm that the element’s actual height is changing. A visual transform can reveal content without affecting document flow.
  • The measured-height fallback breaks after a resize or content update: Recalculate the target when the content or available width changes, and account for transitions interrupted by another state change.
  • A calculation involving auto is rejected or does not work: Use calc-size() for arithmetic based on an intrinsic size, and verify browser support; use interpolate-size for the plain length-to-intrinsic transition.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If what you need is a screenshot of a page or interface—not a CSS height animation—ScreenshotNeo can return an image or PDF with one API request. Its API is separate from the CSS technique above; it does not replace the implementation of an animation in your site.

For example, this cURL request captures a page as WebP. See the ScreenshotNeo API documentation for setup and options:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
  • Cookie banners, newsletter popups, and chat widgets are removed before capture; each cleanup step can be turned off.
  • Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed; responses report the page verdict and billing status in headers.
  • An MCP server provides screenshot tools for AI agents, including Claude, Cursor, and other MCP clients.
  • The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

Sign up for ScreenshotNeo and get 1,000 free screenshots a month with no card.

Frequently Asked Questions

Can a CSS transition animate between two intrinsic sizes?

No. The opt-in enables interpolation between a length-percentage and an intrinsic size keyword; it does not enable interpolation between two different intrinsic keywords.

Should I use height or transform for an accordion?

Use height when the expanded panel should take up space and push following content down. A transform can create a visual reveal without changing document flow, so it suits a different interaction.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.