The max-inline-size property caps how large an element can grow along the inline axis. In everyday horizontal layouts, that usually means limiting width while still letting narrow content stay compact.
01
Upper Limit
Cap inline-axis growth.
02
none Default
No maximum by default.
03
Pixels / %
Fixed and relative caps.
04
Writing Modes
Logical like max-width.
05
Overflow
Pair with scrolling.
06
Related
inline-size, min-inline-size.
Fundamentals
Introduction
The max-inline-size property in CSS defines the maximum size of an element in the inline direction. This property is useful for setting a constraint on the width of an element, especially in layouts where text flow and element sizing need to be controlled.
It is often used in responsive design to ensure that elements do not exceed a certain width, regardless of the container size or screen width.
Definition and Usage
In horizontal writing modes such as English, the inline axis runs left to right, so max-inline-size: 300px; usually caps width. In vertical writing modes, the same property caps height instead.
Pair max-inline-size with overflow: auto when content might exceed the limit, and use it alongside inline-size and min-inline-size for full logical sizing control.
💡
Beginner Tip
Think of max-inline-size as a ceiling: the box can be narrower than the limit, but it cannot grow wider (in horizontal writing) once it hits the maximum.
Foundation
📝 Syntax
The syntax for the max-inline-size property is simple. It can be applied to any block-level or inline-level element:
syntax.css
element{max-inline-size:value;}
Here, value can be any valid CSS length value, such as pixels, percentages, or viewport units, or the keyword none.
The initial value is none, meaning no maximum inline-size constraint.
Length values such as px, rem, and vw set a fixed upper limit.
Percentages are relative to the containing block’s inline size.
Keywords like min-content, max-content, and fit-content cap size based on content.
Use with overflow when content may exceed the maximum and should scroll.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Initial value
none
Applies to
All elements
Inherited
No
Animatable
No
Common use
Scrollable panels, capped cards, responsive max widths in logical layouts
Defaults
🎯 Default Value
The default value of max-inline-size is none. Without explicit styling, the element has no maximum size constraint along the inline axis and can grow as needed based on its content and other sizing properties.
Reference
💎 Property Values
These are the most common values you will use with max-inline-size.
Value
Example
Meaning
length
max-inline-size: 500px;
A specific length value such as px, em, rem, or vw
percentage
max-inline-size: 80%;
A percentage relative to the containing block’s inline size
A fixed maximum inline size in pixels or other length units.
Max 300px
Most common for readable text columns.
50%
Cannot exceed half of the parent container’s inline size.
Max 50%
Useful in responsive layouts.
none
No upper limit — the element can grow freely.
No max limit
Default browser behavior.
fit-content
Maximum follows content while respecting available space.
Fit content max
Good for flexible components.
Scope
Max Inline Size and Writing Modes
max-inline-size follows the writing mode instead of always mapping to horizontal max-width. That is the main reason to choose it over physical properties like max-width.
Horizontal writing (writing-mode: horizontal-tb)
max-inline-size caps width
Vertical writing (writing-mode: vertical-rl)
max-inline-size caps height
inline-size sets the preferred inline dimension; max-inline-size sets the upper limit.
min-inline-size sets the lower limit on the same axis.
Logical properties help components stay correct when text direction or writing mode changes.
Compare
max-inline-size vs max-width
Property
Axis
Best for
max-inline-size
Inline axis (depends on writing mode)
International layouts, reusable components, logical sizing systems
max-width
Always horizontal (physical width)
Simple layouts with fixed maximum widths in horizontal writing
inline-size
Inline axis (depends on writing mode)
Preferred inline dimension paired with max/min limits
height
Always vertical
Simple fixed-height boxes in horizontal writing
Preview
👀 Live Preview
Three boxes with the same long text but different max-inline-size caps:
none — grows with all content.
12rem max — Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
18rem max — Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.
In horizontal writing, these values cap width. Text wraps within the inline limit for better readability.
Hands-On
Examples Gallery
Try max-inline-size with readable text columns, percentage caps, viewport-relative limits, and side-by-side comparisons.
📚 Maximum Inline Caps
Keep text and inline content from stretching too wide on large screens while preserving responsive layouts.
Example 1 — 300px Maximum on a Paragraph
Set a 300px ceiling on the inline axis so a paragraph stays readable even inside a wide container.
max-inline-size-300.html
<style>p{max-inline-size:300px;border:1px solid #ccc;padding:10px;}</style><p>
This paragraph will not exceed 300 pixels in width, even if the containing block is wider.
</p>
Without a maximum, inline content can stretch across the full container. Caps keep line length under control.
🧠 How max-inline-size Works
1
The browser finds the inline axis
Writing mode decides which direction is inline. In normal English pages, that is left to right.
Writing mode
2
You set a maximum ceiling
Choose a length, percentage, keyword, or none to remove the cap entirely.
CSS rule
3
Content grows until it hits the cap
The element can stay smaller than the maximum, but it cannot grow beyond it. Pair with overflow when content might exceed the limit.
Box model
=
📏
Controlled inline dimension
The element stays within your maximum along the inline axis, keeping layouts tidy even with long content.
Compatibility
Browser Compatibility
The max-inline-size property is supported in most modern browsers. As a logical sizing property, it shares the same support profile as inline-size and related logical dimensions. Test across browsers when writing mode or overflow behavior matters.
✓ Baseline · Modern browsers
Logical max sizing in today’s browsers
Chrome, Firefox, Safari, Edge, and Opera all support max-inline-size and related logical properties in current versions.
96%Modern browser support
Google Chrome57+ · Desktop & Mobile
Full support
Mozilla Firefox41+ · Desktop & Mobile
Full support
Apple Safari12.1+ · macOS & iOS
Full support
Microsoft Edge79+ · Chromium
Full support
Opera44+ · Modern versions
Full support
Fallback behavior
For older browsers, pair logical properties with physical ones such as max-width as a fallback.
💻
Internet ExplorerNo support · Use max-width or max-height instead
None
max-inline-size property96% supported
Bottom line: Use max-inline-size confidently in modern projects, especially when writing mode or overflow control matters.
Wrap Up
Conclusion
The max-inline-size property is a useful tool for controlling the maximum size of elements along the inline axis.
By setting appropriate maximum sizes and pairing them with overflow, you can ensure elements fit well within your layout constraints. This is especially useful in responsive designs where maintaining readability and design consistency is crucial.
Pair max-inline-size with overflow: auto when content may exceed the cap
Use it alongside inline-size and min-inline-size for full logical sizing control
Prefer logical max properties in layouts that may change writing mode
Use viewport units like 80vw for responsive maximum widths
Test scroll behavior on touch devices when capping inline content width
❌ Don’t
Cap inline size without deciding what happens to overflow content
Assume max-inline-size always equals max-width in every layout
Confuse max-inline-size with inline-size — one sets a ceiling, the other sets preferred size
Expect percentages to work when the parent inline size is undefined
Skip fallbacks if you must support very old browsers
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about max-inline-size
Use these points when capping logical inline dimensions.
5
Core concepts
📏01
Maximum Cap
Sets the ceiling.
Purpose
📝02
none Default
No maximum limit.
Default
🔄03
Writing Mode
Follows inline axis.
Context
📈04
Overflow Pair
Scroll when capped.
UX
🛠05
Logical Trio
inline, min, max.
System
❓ Frequently Asked Questions
The max-inline-size property sets the maximum size of an element along the inline axis. In horizontal writing, that usually caps width. The element can shrink below this value but cannot grow beyond it.
The default value is none, which means there is no maximum inline-size constraint and the element can grow with its content and container.
max-width always limits horizontal size. max-inline-size follows the writing mode, so it limits width in horizontal writing and height in vertical writing.
Common values include none, auto, length units like px and rem, percentages, and sizing keywords such as max-content and fit-content.
Use it for readable text columns, cards, and responsive layouts where inline content should not stretch too wide on large screens.