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.
.panel { max-block-size: 20rem; overflow: auto; }
Try it
Syntax
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-heightandmax-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-sizeand the two conflict, the minimum wins. - Pair it with overflow. Capping the size without
overflow: autolets the content spill out of the box, which is rarely what you want. - Same axis as
block-size.block-sizesets the preferred size, andmin-block-sizeandmax-block-sizeclamp it, just likeheight,min-heightandmax-height. - Writing modes. Rotating the writing mode changes which physical dimension the cap controls, so a card with
max-block-sizestays sensible in vertical text. - Percentages need a definite parent. If the parent's height is
auto, a percentage value behaves asnone.
Browser support
Supported in all current browsers.
Related
block-sizeโ the preferred logical heightmin-block-sizeโ the logical minimum heightmax-inline-sizeโ the logical maximum widthmax-heightโ the physical equivalent- Logical properties
- Lessons: Width and height, Writing modes