CSS Reference ยท Container Queries and Logical Properties
The min-block-size property
Reference for the CSS min-block-size property: the logical minimum height that follows the writing mode, with a live example and tips for flexible boxes.
The min-block-size property sets the smallest size an element may have along the block axis. In horizontal writing modes that is the height, so it works like min-height; in vertical writing modes it works like min-width.
Unlike a fixed block-size, a minimum lets the box grow when its content needs more room, so text is never cut off or pushed outside.
.card { min-block-size: 8rem; }
Try it
Syntax
min-block-size: auto | <length> | <percentage> | min-content | max-content | fit-content | fit-content(<length-percentage>) | stretch
- Initial value:
auto - Applies to: same as
widthandheight - Inherited: no
- Animatable: yes, as a length or percentage
- Computed value: as for
min-height - Percentages: relative to the block size of the containing block (a percentage only resolves if that size is definite)
Values
| Value | Description |
|---|---|
auto |
For most boxes, behaves as 0. For flex and grid items in the relevant axis it is the automatic minimum size based on content. |
<length> |
A fixed minimum such as 10rem or 100vh. |
<percentage> |
A share of the containing block's block size, which must be definite. |
min-content, max-content, fit-content |
Intrinsic sizing keywords; in the block axis they are usually the same as auto. |
stretch |
The minimum is the full available block space. Newer; check a compatibility table. |
Usage notes
- Prefer a minimum over a fixed size. Text can wrap into more lines on narrow screens, with larger fonts or after translation. A
min-block-sizekeeps a consistent look yet allows growth. - Full-height layouts.
min-block-size: 100vh(or100dvh, to account for mobile browser toolbars) on a page wrapper makes a short page fill the screen, while long pages can still scroll. See dynamic viewport units. - Percentages need a definite parent.
min-block-size: 100%has an effect only if the parent has an explicit block size. In a flex or grid layout, let the container stretch the item instead. - Beats
block-size. If the minimum is larger than the block size, the minimum wins. Amax-block-sizesmaller than the minimum is also overridden by the minimum. - Flex and grid. An item's
autominimum is based on its content in the main axis, so long content can keep it from shrinking. Setmin-block-size: 0on a column flex item that should shrink and scroll (withoverflow: auto). - Writing modes. The physical axis is chosen by the element's own
writing-mode. For layouts that never rotate,min-heightis equivalent.
Browser support
Supported in all current major browsers and part of Baseline; the stretch keyword is newer, so check a compatibility table.
Related
max-block-sizeโ the logical maximum heightblock-sizeโ the logical heightmin-inline-sizeโ the logical minimum widthmin-heightโ the physical property- Lessons: Width and Height, Writing Modes