CSS min-block-size Property
The CSS min-block-size property sets the minimum size of an element along its block axis.
It is a logical sizing property that corresponds to min-height in horizontal writing modes and min-width in vertical writing modes. It prevents an element from becoming smaller than a specified limit while allowing it to grow when additional space is needed.
min-block-size Syntax
The min-block-size property accepts nonnegative lengths, percentages, intrinsic sizing keywords, and supported sizing functions.
Basic Syntax
selector {
min-block-size: 200px;
}
Relative Length
.panel {
min-block-size: 15rem;
}
Percentage Value
.panel {
min-block-size: 50%;
}
Viewport-Relative Size
.panel {
min-block-size: 60vh;
}
Intrinsic Sizing
.panel {
min-block-size: min-content;
}
.panel {
min-block-size: max-content;
}
.panel {
min-block-size: fit-content(300px);
}
Automatic Minimum
.panel {
min-block-size: auto;
}
CSS-Wide Keywords
.panel {
min-block-size: initial;
}
.panel {
min-block-size: inherit;
}
.panel {
min-block-size: unset;
}
.panel {
min-block-size: revert;
}
.panel {
min-block-size: revert-layer;
}
The initial value is auto. Its behavior depends on the element's layout context, including whether it participates in a flex or grid layout.
Property Values
| Value | Description |
|---|---|
auto |
Uses the automatic minimum size determined by the layout rules. This is the initial value. |
<length> |
Sets a minimum block size using units such as px, em, rem, or viewport units. |
<percentage> |
Sets the minimum relative to the containing block's corresponding dimension when that size can be resolved. |
min-content |
Uses the intrinsic minimum-content size along the block axis. |
max-content |
Uses the intrinsic maximum-content size along the block axis. |
fit-content() |
Uses intrinsic sizing while considering the specified available-space limit. |
stretch |
Uses the available containing-block size to establish a minimum for the margin box. Support varies. |
initial |
Resets the property to auto. |
inherit |
Uses the computed value from the parent element. |
unset |
Resets the property to auto because it is not inherited. |
revert |
Reverts the property according to cascade origin rules. |
revert-layer |
Reverts the property according to cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | auto |
| Inherited | No |
| Applies to | Elements that accept width or height constraints |
| Computed value | As specified, with relative lengths converted to absolute lengths |
| Animation type | By computed value type |
| Logical dimension | Block axis |
| Physical equivalent | min-height or min-width, depending on writing mode |
How It Works
The block axis is the direction in which block-level content progresses. In horizontal writing modes, it runs vertically. In vertical writing modes, it runs horizontally.
The min-block-size property establishes a lower limit along this axis. The element can grow beyond the minimum when its content or layout requires more space.
Set a Minimum Block Size
.panel {
min-block-size: 200px;
}
In horizontal writing mode, the panel must be at least 200 pixels tall, subject to applicable sizing rules.
Content Smaller Than the Minimum
.panel {
block-size: 100px;
min-block-size: 200px;
}
The minimum overrides the smaller preferred block size, resulting in a used block size of at least 200 pixels.
Content Larger Than the Minimum
.panel {
min-block-size: 200px;
}
With automatic block sizing, the panel can grow beyond 200 pixels when additional content requires more space.
Automatic Minimum
.panel {
min-block-size: auto;
}
The automatic minimum is determined by the layout context. For ordinary block layout, it generally does not impose an additional minimum beyond the normal sizing rules. Flex and grid items can have content-based automatic minimums.
Important Consideration
A minimum block size does not establish a maximum. Use max-block-size when the element must also have an upper size limit.
Logical vs. Physical Sizing
Physical sizing properties control fixed dimensions such as width and height. Logical sizing properties follow the block and inline axes established by the writing mode.
Physical Minimum Height
.panel {
min-height: 200px;
}
This always limits the physical height.
Logical Minimum Block Size
.panel {
min-block-size: 200px;
}
This limits the height in horizontal writing modes and the width in vertical writing modes.
Logical Sizing Properties
| Property | Purpose |
|---|---|
block-size |
Sets the preferred size along the block axis. |
min-block-size |
Sets the minimum size along the block axis. |
max-block-size |
Sets the maximum size along the block axis. |
inline-size |
Sets the preferred size along the inline axis. |
min-inline-size |
Sets the minimum size along the inline axis. |
max-inline-size |
Sets the maximum size along the inline axis. |
Logical sizing is useful for layouts that must adapt to different writing modes without changing physical width and height declarations.
Writing Modes
The physical dimension controlled by min-block-size depends on the element's computed writing-mode.
| Writing Mode | Block Axis | Physical Equivalent |
|---|---|---|
horizontal-tb |
Vertical | min-height |
vertical-rl |
Horizontal | min-width |
vertical-lr |
Horizontal | min-width |
sideways-rl |
Horizontal | min-width |
sideways-lr |
Horizontal | min-width |
Horizontal Writing Mode
.horizontal-panel {
writing-mode: horizontal-tb;
min-block-size: 200px;
}
The minimum applies to the element's physical height.
Vertical Writing Mode
.vertical-panel {
writing-mode: vertical-rl;
min-block-size: 200px;
}
The minimum applies to the element's physical width.
Text Direction
The direction property affects inline progression, but switching between left-to-right and right-to-left text does not by itself change the physical dimension controlled by the block axis.
Important Consideration
The logical block axis follows the element's writing mode, not simply the language used in its content.
Length and Percentage Values
Lengths and percentages provide several ways to establish a minimum block dimension.
Pixels
.panel {
min-block-size: 250px;
}
The minimum block size is 250 pixels.
Root Font Units
.panel {
min-block-size: 15rem;
}
The minimum is calculated relative to the root element's font size.
Viewport Height
.panel {
min-block-size: 60vh;
}
The minimum is 60% of the viewport height. The vh unit always refers to viewport height, regardless of writing mode.
Dynamic Viewport Height
.panel {
min-block-size: 100dvh;
}
The dvh unit uses the dynamic viewport height, which can change as mobile browser interface elements appear or disappear.
Percentage Value
.container {
block-size: 400px;
}
.panel {
min-block-size: 50%;
}
When the containing block has a definite block size of 400 pixels, the panel's minimum resolves to 200 pixels.
Unresolved Percentages
If the containing block's corresponding size depends on its content, a percentage minimum may not resolve to a definite value. Its behavior then depends on the applicable sizing and layout rules.
Negative Values
.panel {
min-block-size: -100px;
}
Negative lengths and percentages are invalid. Zero and positive values are allowed.
Intrinsic Sizing Values
Intrinsic sizing values establish minimum dimensions using the element's content and available layout space.
min-content
.panel {
min-block-size: min-content;
}
The minimum is based on the element's intrinsic minimum-content size along the block axis.
max-content
.panel {
min-block-size: max-content;
}
The minimum is based on the intrinsic maximum-content size along the block axis.
fit-content()
.panel {
min-block-size: fit-content(300px);
}
The fit-content() function uses intrinsic sizing limits while considering the specified available-space value.
stretch
.panel {
min-block-size: stretch;
}
The stretch keyword establishes a minimum based on the containing block's available block dimension, accounting for the element's margin box. Browser support varies.
Important Consideration
Intrinsic sizing behavior depends on content and layout context. Check browser compatibility when using newer sizing keywords or functions.
Minimum and Maximum Sizing
The min-block-size property works with block-size and max-block-size to control an element's preferred, minimum, and maximum block dimensions.
Block Size Range
.panel {
min-block-size: 150px;
max-block-size: 400px;
}
The panel cannot be smaller than 150 pixels or larger than 400 pixels along its block axis, subject to the applicable sizing rules.
Preferred Block Size Below the Minimum
.panel {
block-size: 100px;
min-block-size: 200px;
}
The minimum overrides the smaller preferred block size.
Preferred Block Size Above the Minimum
.panel {
block-size: 300px;
min-block-size: 200px;
}
The preferred block size remains 300 pixels because it satisfies the minimum.
Minimum Takes Precedence
.panel {
min-block-size: 400px;
max-block-size: 250px;
}
When the minimum exceeds the maximum, the minimum takes precedence.
Box Sizing
.panel {
box-sizing: border-box;
min-block-size: 200px;
padding: 20px;
border: 2px solid #64748b;
}
With border-box, the specified minimum includes padding and borders. With content-box, it applies to the content box.
Responsive Layouts
Minimum block dimensions are useful for page sections, cards, and interface components that need consistent minimum sizes without preventing content from expanding.
Full-Viewport Section
.hero {
min-block-size: 100vh;
display: grid;
place-items: center;
}
In horizontal writing mode, the section is at least as tall as the viewport and can grow when its content requires additional space.
Dynamic Viewport Section
.hero {
min-block-size: 100vh;
min-block-size: 100dvh;
}
The first declaration provides a fallback. Supporting browsers use the dynamic viewport height from the second declaration.
Consistent Card Size
.card {
min-block-size: 180px;
padding: 20px;
box-sizing: border-box;
}
Cards with short content maintain a minimum size, while cards with longer content can grow.
Responsive Minimum
.content-panel {
min-block-size: clamp(150px, 30vh, 350px);
}
The minimum block size responds to the viewport height while remaining between 150 and 350 pixels.
Media Query Adjustment
.content-panel {
min-block-size: 300px;
}
@media (max-width: 767px) {
.content-panel {
min-block-size: 180px;
}
}
The minimum becomes smaller on narrow screens, allowing more flexible layouts.
Important Consideration
A large minimum block size can create unnecessary empty space on short viewports. Test responsive constraints with different screen sizes and text scaling.
Flexbox and Grid
Minimum sizing is particularly important in flex and grid layouts because items can have automatic minimum sizes based on their content.
Flex Item Minimum
.flex-container {
display: flex;
flex-direction: column;
block-size: 400px;
}
.flex-item {
min-block-size: 0;
overflow-y: auto;
}
Setting min-block-size: 0 allows the flex item to shrink below its content-based automatic minimum when the block axis is the relevant flex dimension. The overflow rule can then provide scrolling when needed.
Grid Item Minimum
.grid-container {
display: grid;
grid-template-rows: auto minmax(0, 1fr);
block-size: 400px;
}
.grid-content {
min-block-size: 0;
overflow-y: auto;
}
The grid track can shrink within the available space, and the grid item can scroll when its content exceeds the assigned area.
Minimum Card Height
.card-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 16px;
}
.card {
min-block-size: 180px;
padding: 20px;
box-sizing: border-box;
}
Each card has a minimum block size of 180 pixels. Cards can expand when additional content requires more space.
Important Consideration
The automatic minimum size of a flex or grid item is not always zero. Use an explicit minimum such as 0 when the layout requires an item to shrink below its content-based minimum, and handle overflow appropriately.
min-block-size Example
This example compares a box with an automatic minimum block size and a box with a minimum block size of 140 pixels. Both contain a short paragraph.
HTML Example
<div class="min-block-demo">
<div class="min-block-item">
<h3>min-block-size: auto</h3>
<div class="min-block-box automatic">
<p>A short paragraph of content.</p>
</div>
</div>
<div class="min-block-item">
<h3>min-block-size: 140px</h3>
<div class="min-block-box limited">
<p>A short paragraph of content.</p>
</div>
</div>
</div>
CSS Example
.min-block-demo {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16px;
}
.min-block-item {
min-width: 0;
}
.min-block-item h3 {
margin: 0 0 12px;
font-size: 1rem;
}
.min-block-box {
box-sizing: border-box;
padding: 15px;
background-color: #dbeafe;
border: 2px solid #2563eb;
border-radius: 6px;
}
.min-block-box p {
margin: 0;
}
.automatic {
min-block-size: auto;
}
.limited {
min-block-size: 140px;
}
@media (max-width: 575px) {
.min-block-demo {
grid-template-columns: 1fr;
}
}
min-block-size: auto
A short paragraph of content.
min-block-size: 140px
A short paragraph of content.
The first box uses the block size needed by its content. The second box remains at least 140 pixels tall in horizontal writing mode, even though its content requires less space.
Vertical Writing Mode Example
<div class="vertical-block-demo">
<p>Logical sizing follows the block axis.</p>
</div>
.vertical-block-demo {
writing-mode: vertical-rl;
block-size: 100px;
min-block-size: 180px;
inline-size: 160px;
box-sizing: border-box;
padding: 15px;
background-color: #dcfce7;
border: 2px solid #16a34a;
}
In vertical writing mode, the block axis runs horizontally. The minimum block size overrides the smaller preferred block size, producing a box at least 180 pixels wide.
Common Mistakes
Confusing min-block-size with block-size
.box {
min-block-size: 200px;
}
This establishes a minimum rather than a fixed block size. The element can grow beyond 200 pixels.
Assuming the Property Always Controls Height
In vertical writing modes, min-block-size controls physical width. Use min-height when a fixed physical height constraint is required.
Using Negative Values
.box {
min-block-size: -100px;
}
Negative lengths and percentages are invalid.
Conflicting Minimum and Maximum Values
.box {
min-block-size: 400px;
max-block-size: 200px;
}
The minimum takes precedence when it exceeds the maximum.
Expecting Percentages to Always Resolve
.box {
min-block-size: 50%;
}
The containing block generally needs a definite corresponding size for the percentage to produce the expected minimum.
Ignoring Automatic Minimum Sizes
Flex and grid items can resist shrinking because of content-based automatic minimums. An explicit min-block-size: 0 can help when the block axis is the dimension that must shrink.
Confusing Block and Inline Axes
min-block-size constrains the block axis. Use min-inline-size for the inline axis.
Forgetting Box Sizing
With content-box, padding and borders add to the specified minimum content-box size. Use border-box when the minimum should include them.
Important Considerations
Keep the following points in mind when using min-block-size:
- The property sets the minimum size along the block axis.
- Its initial value is
auto. - The property is not inherited.
- In horizontal writing modes, it corresponds to
min-height. - In vertical writing modes, it corresponds to
min-width. - It does not prevent an element from growing beyond the minimum.
- Length and percentage values must be nonnegative.
- Percentage values depend on the containing block's corresponding dimension.
- Intrinsic sizing values depend on content and layout context.
min-block-sizetakes precedence when it exceedsmax-block-size.block-sizespecifies a preferred size, whilemin-block-sizeestablishes a lower limit.box-sizingaffects whether padding and borders are included in the specified minimum.- The property is useful for page sections, cards, and responsive components.
- Flex and grid items can have content-based automatic minimum sizes.
- Setting
min-block-size: 0can allow certain flex and grid items to shrink. - Logical sizing adapts to the element's writing mode.
- Use
min-inline-sizewhen the constraint should follow the inline axis. - Test minimum sizes on narrow screens and with enlarged text.
Browser Support
The CSS min-block-size property is Baseline - Widely available. It is supported in current versions of major browsers, including Chrome, Edge, Firefox, and Safari.
Basic length, percentage, and auto values have broad support. Some newer intrinsic sizing values, including stretch, may have different compatibility requirements.
For current compatibility information, visit Can I Use? and search for min-block-size.
When supporting older browsers, test logical sizing together with the writing modes and layout systems used by your website.
Specifications
The min-block-size property is defined in CSS Logical Properties and Values Level 1.
CSS Logical Properties and Values Level 1: Logical Dimension Properties
The specification defines logical sizing properties and their mapping to physical dimensions according to writing mode.
For additional documentation and examples, consult MDN Web Docs.
