Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Container Queries and Logical Properties

The max-block-size property

Reference for the CSS max-block-size property: the logical maximum height, how it follows the writing mode, its values, examples and usage notes.

The max-block-size property sets the largest size an element may have along the block axis, the direction in which blocks stack. In ordinary horizontal text (English, Spanish, Hindi and so on) the block axis is vertical, so max-block-size behaves like max-height. In a vertical writing mode, the block axis is horizontal and the property behaves like max-width instead.

It is the logical counterpart of max-height. Use it when a layout should adapt to the writing mode of its content without rewriting every size.

CSS
.panel { max-block-size: 20rem; overflow: auto; }

Try it

A capped block size
Following the writing mode

Syntax

CSS
max-block-size: none | <length> | <percentage> | min-content | max-content | fit-content | fit-content(<length-percentage>);
  • Initial value: none
  • Applies to: the same elements as max-height and max-width (not non-replaced inline elements or table rows and row groups)
  • Inherited: no
  • Percentages: relative to the block size of the containing block
  • Animatable: yes (as a length or percentage)
  • Computed value: the percentage as specified, or the absolute length, or none

Values

Value Description
none No limit on the block size.
<length> A fixed maximum such as 20rem or 300px. Negative values are invalid.
<percentage> A share of the containing block's block size. It only resolves if that size does not depend on the element's content.
min-content, max-content, fit-content Intrinsic sizing keywords. Support varies on the block axis, so test before relying on them.

Usage notes

  • It only caps. The element can still be smaller. If you also set min-block-size and the two conflict, the minimum wins.
  • Pair it with overflow. Capping the size without overflow: auto lets the content spill out of the box, which is rarely what you want.
  • Same axis as block-size. block-size sets the preferred size, and min-block-size and max-block-size clamp it, just like height, min-height and max-height.
  • Writing modes. Rotating the writing mode changes which physical dimension the cap controls, so a card with max-block-size stays sensible in vertical text.
  • Percentages need a definite parent. If the parent's height is auto, a percentage value behaves as none.

Browser support

Supported in all current browsers.