# max-height

> The `max-height` CSS property sets the maximum height of an element's content area.

## How do I make a dropdown scroll after a max height in CSS?

The property that sets the maximum height of an element. It prevents the element from growing taller than the specified value, ensuring that its content doesn't overflow beyond this limit, which helps to control the layout and appearance.

- Topic: Sizes & Margins
- Type: property
- Browser support: Chrome 18+, Chrome Android 18+, Edge 12+, Firefox 1+, Firefox Android 4+, Safari 1.3+, Safari iOS 1+

## Example

Wrong:

```css
.menu {
  max-height: 300px;
}
```

Right:

```css
.menu {
  max-height: 300px;
  overflow-y: auto;
}
```

`max-height` alone lets extra items overflow; `overflow-y: auto` adds a scrollbar only when needed.

## Common mistakes

- Content spills out of a list with `max-height` because `overflow` was left visible.
- Animating `max-height` to '1000px' makes the collapse start with a delay.

## Key points

- Elements with `max-height` and changing content also set `overflow-y: auto`.
- Menus and dialogs cap height relative to the viewport, like `max-height: 80dvh`.
- Expand animations don't rely on a large `max-height` guess, which makes timing uneven.

## Interview questions

### What is the default value of max-height?

'none', so the element has no height limit.

### Does max-height override height?

Yes. If `height` is larger than `max-height`, the element stops at the `max-height` value.

### Why does a max-height transition feel delayed?

The transition runs over the full `max-height` range, so with a large guessed value most of the time passes before the visible size changes.

## Related cards

- [min-height](https://wonderium.dev/css/min-height.md)
- [height](https://wonderium.dev/css/height.md)
- [overflow](https://wonderium.dev/css/overflow.md)
- [Viewport Units](https://wonderium.dev/css/viewport-units.md)
- [transition](https://wonderium.dev/css/transition.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/max-height
- Last updated: 2026-11-25
