CSS min-inline-size Property
The CSS min-inline-size property sets the minimum size of an element along its inline axis.
It is a logical sizing property that corresponds to min-width in horizontal writing modes and min-height in vertical writing modes. It prevents an element from becoming smaller than a specified minimum while allowing it to grow when the layout requires additional space.
min-inline-size Syntax
The min-inline-size property accepts nonnegative lengths, percentages, intrinsic sizing keywords, and supported sizing functions.
Basic Syntax
selector {
min-inline-size: 200px;
}
Relative Length
.panel {
min-inline-size: 15rem;
}
Percentage Value
.panel {
min-inline-size: 50%;
}
Viewport-Relative Size
.panel {
min-inline-size: 30vw;
}
Intrinsic Sizing
.panel {
min-inline-size: min-content;
}
.panel {
min-inline-size: max-content;
}
.panel {
min-inline-size: fit-content(300px);
}
Automatic Minimum
.panel {
min-inline-size: auto;
}
CSS-Wide Keywords
.panel {
min-inline-size: initial;
}
.panel {
min-inline-size: inherit;
}
.panel {
min-inline-size: unset;
}
.panel {
min-inline-size: revert;
}
.panel {
min-inline-size: revert-layer;
}
The initial value is auto. Its behavior depends on the element's layout context, particularly when the element participates in a flex or grid layout.
Property Values
| Value | Description |
|---|---|
auto |
Uses the automatic minimum size determined by the layout context. This is the initial value. |
<length> |
Sets a minimum inline size using units such as px, em, rem, or viewport units. |
<percentage> |
Sets a minimum relative to the containing block's corresponding dimension when the percentage can be resolved. |
min-content |
Uses the intrinsic minimum-content size along the inline axis. |
max-content |
Uses the intrinsic maximum-content size along the inline axis. |
fit-content() |
Uses intrinsic sizing limits together with the supplied available-space value. |
stretch |
Establishes a minimum based on the available inline dimension of the containing block, accounting for the element's margin box. Browser 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 | Inline axis |
| Physical equivalent | min-width or min-height, depending on writing mode |
How It Works
The inline axis is the direction in which text and other inline content progresses. In horizontal writing modes, it runs horizontally. In vertical writing modes, it runs vertically.
The min-inline-size property establishes a lower size limit along this axis. An element can become larger than the minimum when its content or layout requires additional space.
Set a Minimum Inline Size
.panel {
min-inline-size: 200px;
}
In horizontal writing mode, the panel must be at least 200 pixels wide, subject to applicable sizing rules.
Preferred Size Below the Minimum
.panel {
inline-size: 100px;
min-inline-size: 200px;
}
The minimum overrides the smaller preferred inline size, producing a used inline size of at least 200 pixels.
Preferred Size Above the Minimum
.panel {
inline-size: 300px;
min-inline-size: 200px;
}
The preferred inline size remains 300 pixels because it satisfies the minimum.
Automatic Minimum
.panel {
min-inline-size: auto;
}
The automatic minimum depends on the layout context. Ordinary block layout generally does not impose an additional minimum, while flex and grid items may use content-based automatic minimum sizes.
Important Consideration
A minimum inline size does not establish a maximum. Use max-inline-size when an element must also have an upper inline-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 Width
.panel {
min-width: 200px;
}
This always constrains the physical width.
Logical Minimum Inline Size
.panel {
min-inline-size: 200px;
}
This constrains the width in horizontal writing modes and the height in vertical writing modes.
Logical Sizing Properties
| Property | Purpose |
|---|---|
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. |
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. |
Logical sizing is useful for components that need to work with multiple writing modes without rewriting physical width and height declarations.
Writing Modes
The physical dimension controlled by min-inline-size depends on the element's computed writing-mode.
| Writing Mode | Inline Axis | Physical Equivalent |
|---|---|---|
horizontal-tb |
Horizontal | min-width |
vertical-rl |
Vertical | min-height |
vertical-lr |
Vertical | min-height |
sideways-rl |
Vertical | min-height |
sideways-lr |
Vertical | min-height |
Horizontal Writing Mode
.horizontal-panel {
writing-mode: horizontal-tb;
min-inline-size: 200px;
}
The minimum applies to the element's physical width.
Vertical Writing Mode
.vertical-panel {
writing-mode: vertical-rl;
min-inline-size: 200px;
}
The minimum applies to the element's physical height.
Text Direction
The direction property changes the direction of inline progression, but switching between left-to-right and right-to-left text does not change the physical dimension controlled by the inline axis.
Important Consideration
The logical inline axis follows the element's writing mode. It does not depend solely on the language used in the content.
Length and Percentage Values
Lengths and percentages provide flexible ways to establish minimum inline dimensions.
Pixels
.panel {
min-inline-size: 250px;
}
The minimum inline size is 250 pixels.
Root Font Units
.panel {
min-inline-size: 15rem;
}
The minimum is calculated relative to the root element's font size.
Character Units
.panel {
min-inline-size: 20ch;
}
The ch unit is based on the advance width of the 0 glyph in the element's font. It can be useful for text-related sizing.
Viewport Width
.panel {
min-inline-size: 30vw;
}
The minimum is 30% of the viewport width. The vw unit always refers to viewport width, regardless of writing mode.
Percentage Value
.container {
inline-size: 600px;
}
.panel {
min-inline-size: 50%;
}
When the containing block has a definite corresponding size of 600 pixels, the panel's minimum resolves to 300 pixels.
Calculated Minimum
.panel {
min-inline-size: calc(20rem + 2vw);
}
The minimum combines a root-font-relative length with a viewport-relative length.
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 depends on the applicable layout and sizing rules.
Negative Values
.panel {
min-inline-size: -100px;
}
Negative lengths and percentages are invalid. Zero and positive values are permitted.
Intrinsic Sizing Values
Intrinsic sizing values establish minimum dimensions using the element's content and the available layout space.
min-content
.panel {
min-inline-size: min-content;
}
The minimum is based on the intrinsic minimum-content size along the inline axis. For horizontal text, this is often influenced by the longest unbreakable content segment.
max-content
.panel {
min-inline-size: max-content;
}
The minimum is based on the intrinsic maximum-content size. For horizontal text, this generally reflects the width needed without soft wrapping.
fit-content()
.panel {
min-inline-size: fit-content(300px);
}
The fit-content() function uses intrinsic sizing limits while considering the specified available-space value.
stretch
.panel {
min-inline-size: stretch;
}
The stretch keyword establishes a minimum based on the containing block's available inline dimension, accounting for the element's margin box. Browser support varies.
Important Consideration
Intrinsic sizing values depend on content and layout context. Check browser compatibility when using newer sizing keywords or functions.
Minimum and Maximum Sizing
The min-inline-size property works with inline-size and max-inline-size to control an element's preferred, minimum, and maximum inline dimensions.
Inline Size Range
.panel {
min-inline-size: 150px;
max-inline-size: 400px;
}
The panel's used inline size is constrained between 150 and 400 pixels, subject to applicable sizing rules.
Preferred Size Below the Minimum
.panel {
inline-size: 100px;
min-inline-size: 200px;
}
The minimum overrides the smaller preferred inline size.
Preferred Size Above the Minimum
.panel {
inline-size: 300px;
min-inline-size: 200px;
}
The preferred inline size remains 300 pixels because it satisfies the minimum.
Minimum Takes Precedence
.panel {
min-inline-size: 400px;
max-inline-size: 250px;
}
When the minimum exceeds the maximum, the minimum takes precedence.
Box Sizing
.panel {
box-sizing: border-box;
min-inline-size: 200px;
padding: 20px;
border: 2px solid #64748b;
}
With border-box, the specified minimum includes padding and borders. With content-box, the minimum applies to the content box.
Responsive Layouts
Minimum inline dimensions are useful for buttons, form controls, cards, and other interface components that need a consistent minimum size.
Minimum Button Size
.button {
display: inline-block;
min-inline-size: 120px;
padding: 12px 20px;
box-sizing: border-box;
text-align: center;
}
The button maintains a minimum inline size of 120 pixels and can expand when its label requires more space.
Minimum Form Control Size
.form-input {
inline-size: 100%;
min-inline-size: 180px;
box-sizing: border-box;
}
The form control maintains a minimum inline size of 180 pixels. On containers narrower than this minimum, horizontal overflow may occur.
Responsive Minimum
.panel {
min-inline-size: clamp(150px, 25vw, 300px);
}
The minimum responds to the viewport width while remaining between 150 and 300 pixels.
Media Query Adjustment
.panel {
min-inline-size: 300px;
}
@media (max-width: 767px) {
.panel {
min-inline-size: 0;
}
}
The minimum is removed on narrow screens, allowing the panel to shrink when its layout permits.
Important Consideration
A large minimum inline size can cause overflow on narrow screens. Choose minimums that remain practical for the available space and content.
Flexbox and Grid
Flex and grid items can have content-based automatic minimum sizes. This can prevent them from shrinking as expected, particularly when the inline axis is horizontal.
Flex Item Minimum
.flex-container {
display: flex;
inline-size: 100%;
}
.flex-item {
flex: 1;
min-inline-size: 0;
}
In horizontal writing mode with a row-direction flex container, setting min-inline-size: 0 allows the item to shrink below its content-based automatic minimum.
Grid Item Minimum
.grid-container {
display: grid;
grid-template-columns: minmax(0, 1fr) 200px;
}
.grid-content {
min-inline-size: 0;
}
The first grid track can shrink below its content's intrinsic minimum. The grid item can also shrink when its automatic minimum would otherwise prevent it.
Minimum Card Size
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 16px;
}
.card {
min-inline-size: 0;
padding: 20px;
box-sizing: border-box;
}
The grid creates columns with a preferred minimum track width of 220 pixels. Setting the card's minimum inline size to zero allows it to shrink within its assigned track when necessary.
Important Consideration
Setting min-inline-size: 0 does not automatically make long unbreakable content wrap. Additional wrapping or overflow rules may still be necessary.
Overflow Behavior
A minimum inline size establishes a lower limit but does not guarantee that an element will fit inside its container.
Minimum Larger Than Available Space
.panel {
min-inline-size: 500px;
}
In horizontal writing mode, the panel may overflow when its containing block is narrower than 500 pixels.
Allow Long Text to Wrap
.panel {
min-inline-size: 0;
overflow-wrap: anywhere;
}
The minimum allows the element to shrink, while overflow-wrap permits long text segments to break when necessary.
Scrollable Content
.code-panel {
min-inline-size: 0;
overflow-x: auto;
}
In horizontal writing mode, this allows a constrained code panel to scroll horizontally when its content exceeds the available width.
Important Consideration
Use appropriate wrapping and overflow rules to keep content accessible. Avoid setting unnecessarily large minimums that force page-level horizontal scrolling.
min-inline-size Example
This example compares a box with an automatic minimum inline size and a box with a minimum inline size of 220 pixels. Both boxes use a preferred width of 120 pixels to make the difference visible.
HTML Example
<div class="min-inline-demo">
<div class="min-inline-item">
<h3>min-inline-size: auto</h3>
<div class="min-inline-box automatic">
<p>Sample content</p>
</div>
</div>
<div class="min-inline-item">
<h3>min-inline-size: 220px</h3>
<div class="min-inline-box limited">
<p>Sample content</p>
</div>
</div>
</div>
CSS Example
.min-inline-demo {
display: grid;
gap: 20px;
padding: 20px;
background-color: #f1f5f9;
}
.min-inline-item h3 {
margin: 0 0 12px;
font-size: 1rem;
}
.min-inline-box {
box-sizing: border-box;
inline-size: 120px;
padding: 15px;
background-color: #dbeafe;
border: 2px solid #2563eb;
border-radius: 6px;
}
.min-inline-box p {
margin: 0;
}
.automatic {
min-inline-size: auto;
}
.limited {
min-inline-size: 220px;
}
min-inline-size: auto
Sample content
min-inline-size: 220px
Sample content
The first box uses its preferred inline size of 120 pixels. The second box expands to 220 pixels because its minimum inline size overrides the smaller preferred size.
Vertical Writing Mode Example
<div class="vertical-inline-demo">
<p>Logical sizing follows the inline axis.</p>
</div>
.vertical-inline-demo {
writing-mode: vertical-rl;
inline-size: 100px;
min-inline-size: 180px;
block-size: 160px;
box-sizing: border-box;
padding: 15px;
background-color: #dcfce7;
border: 2px solid #16a34a;
}
In vertical writing mode, the inline axis runs vertically. The minimum inline size overrides the smaller preferred inline size, producing a box at least 180 pixels tall.
Common Mistakes
Confusing min-inline-size with inline-size
.box {
min-inline-size: 200px;
}
This establishes a minimum rather than a fixed inline size. The element can become larger when necessary.
Assuming the Property Always Controls Width
In vertical writing modes, min-inline-size controls physical height. Use min-width when a fixed physical width constraint is required.
Using Negative Values
.box {
min-inline-size: -100px;
}
Negative lengths and percentages are invalid.
Conflicting Minimum and Maximum Values
.box {
min-inline-size: 400px;
max-inline-size: 200px;
}
The minimum takes precedence when it exceeds the maximum.
Expecting Percentages to Always Resolve
.box {
min-inline-size: 50%;
}
Percentage sizing depends on the containing block's corresponding dimension and the applicable layout rules.
Ignoring Automatic Minimum Sizes
Flex and grid items can resist shrinking because of content-based automatic minimums. Setting min-inline-size: 0 can help when the inline axis is the dimension that must shrink.
Confusing Inline and Block Axes
min-inline-size constrains the inline axis. Use min-block-size for the block 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-inline-size:
- The property sets the minimum size along the inline axis.
- Its initial value is
auto. - The property is not inherited.
- In horizontal writing modes, it corresponds to
min-width. - In vertical writing modes, it corresponds to
min-height. - 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-inline-sizetakes precedence when it exceedsmax-inline-size.inline-sizesets a preferred size, whilemin-inline-sizeestablishes a lower limit.box-sizingaffects whether padding and borders are included in the specified minimum.- The property is useful for buttons, form controls, cards, and responsive components.
- Flex and grid items can have content-based automatic minimum sizes.
- Setting
min-inline-size: 0can allow certain flex and grid items to shrink. - Large minimums can cause overflow on narrow screens.
- Logical sizing adapts to the element's writing mode.
- Use
min-block-sizewhen the constraint should follow the block axis. - Test minimum sizes with different viewport dimensions and enlarged text.
Browser Support
The CSS min-inline-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. Newer intrinsic sizing values, including stretch, may have different compatibility requirements.
For current compatibility information, visit Can I Use? and search for min-inline-size.
When supporting older browsers, test logical sizing together with the writing modes and layout systems used by your website.
Specifications
The min-inline-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.
