Smooth height transitions are possible in CSS.
Animating from height: 0 to height: auto has traditionally been awkward because the browser could not interpolate an intrinsic size.
There are several ways to handle it:
- A fixed
max-height, which is simple but requires a guessed upper limit. - A transform, which looks smooth but does not move surrounding content.
- CSS Grid with a row transitioning from
0frto1fr. interpolate-size: allow-keywords, which allows transitions to intrinsic sizing keywords such asauto.calc-size(), which lets calculations work with intrinsic sizes.
The Grid method is the most practical fallback when surrounding content needs to move. interpolate-size and calc-size() are cleaner, but they still need progressive enhancement because browser availability is limited.
I cover all five approaches with interactive examples in the full article:
https://theosoti.com/blog/height-transition/
Want to build modern interfaces with less JavaScript?
I wrote a guide about building modern UI with HTML and CSS first. It covers practical patterns you can use before reaching for JavaScript.
Learn more