The max-block-size property caps how large an element can grow along the block axis. In everyday horizontal layouts, that usually means limiting height while still letting shorter content stay compact.
01
Upper Limit
Cap block-axis growth.
02
none Default
No maximum by default.
03
Pixels / %
Fixed and relative caps.
04
Writing Modes
Logical like max-height.
05
Overflow
Pair with scrolling.
06
Related
block-size, min-block-size.
Fundamentals
Introduction
The max-block-size property in CSS defines the maximum size of a block-level element along the block axis. This property is useful for controlling the maximum height or width of an element in a block formatting context, depending on the writing mode of the document.
By specifying a maximum size, you can prevent elements from growing beyond a certain point, which helps maintain layout and design consistency across different devices and screen sizes.
Definition and Usage
In horizontal writing modes such as English, the block axis runs top to bottom, so max-block-size: 400px; usually caps height. In vertical writing modes, the same property caps width instead.
Pair max-block-size with overflow: auto when content might exceed the limit, and use it alongside block-size and min-block-size for full logical sizing control.
💡
Beginner Tip
Think of max-block-size as a ceiling: the box can be shorter than the limit, but it cannot grow taller (in horizontal writing) once it hits the maximum.
Foundation
📝 Syntax
Write max-block-size with a length, percentage, sizing keyword, or none:
The initial value is none, meaning no maximum block-size constraint.
Length values such as px, rem, and vh set a fixed upper limit.
Percentages are relative to the containing block’s block 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 heights in logical layouts
Defaults
🎯 Default Value
The default value of max-block-size is none. Without explicit styling, the element has no maximum size constraint along the block 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-block-size.
Value
Example
Meaning
none
max-block-size: none;
No maximum block-size constraint (default)
Length
max-block-size: 300px;
Defines a fixed maximum size using units like px or rem
Percentage
max-block-size: 50%;
Maximum size relative to the containing block’s block dimension
max-content
max-block-size: max-content;
Caps size at the content’s intrinsic maximum block size
min-content
max-block-size: min-content;
Caps size at the content’s intrinsic minimum block size
fit-content
max-block-size: fit-content;
Allows growth to fit content without exceeding available space
A fixed maximum block size in pixels or other length units.
Max 400px
Most common for scrollable panels.
50%
Cannot exceed half of the parent container’s block 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 Block Size and Writing Modes
max-block-size follows the writing mode instead of always mapping to vertical max-height. That is the main reason to choose it over physical properties like max-height.
Horizontal writing (writing-mode: horizontal-tb)
max-block-size caps height
Vertical writing (writing-mode: vertical-rl)
max-block-size caps width
block-size sets the preferred block dimension; max-block-size sets the upper limit.
min-block-size sets the lower limit on the same axis.
Logical properties help components stay correct when text direction or writing mode changes.
Compare
max-block-size vs max-height
Property
Axis
Best for
max-block-size
Block axis (depends on writing mode)
International layouts, reusable components, logical sizing systems
max-height
Always vertical
Simple pages with fixed max heights in horizontal writing
block-size
Block axis (depends on writing mode)
Preferred block 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-block-size caps:
none — grows with all content.
4rem max — Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
6rem 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 height. Scrollbars appear when content exceeds the limit.
Hands-On
Examples Gallery
Try max-block-size with fixed caps, scrollable panels, viewport-relative limits, and side-by-side comparisons.
📚 Maximum Block Caps
Prevent panels and cards from growing too tall while still letting short content stay compact.
Example 1 — 400px Maximum with Scrolling
Set a 400px ceiling on the block axis and add scrolling when content exceeds the limit.
max-block-size-400.html
<style>.box{max-block-size:400px;overflow:auto;background-color:lightgray;}</style><divclass="box">
Long paragraph content goes here…
</div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
How It Works
The box grows with its content until it hits 400px along the block axis, then overflow: auto adds a scrollbar instead of letting text spill out.
Example 2 — Compact Scrollable Panel
Use a smaller cap for sidebar notes, comment threads, or any area that should stay short on the page.
Without a maximum, the box expands freely. With caps, the same content stops at the ceiling and scrolls inside the box.
🧠 How max-block-size Works
1
The browser finds the block axis
Writing mode decides which direction is block. In normal English pages, that is top to bottom.
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 block dimension
The element stays within your maximum along the block axis, keeping layouts tidy even with long content.
Compatibility
Browser Compatibility
The max-block-size property is supported in most modern browsers. As a logical sizing property, it shares the same support profile as block-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-block-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-height as a fallback.
💻
Internet ExplorerNo support · Use max-height or max-width instead
None
max-block-size property96% supported
Bottom line: Use max-block-size confidently in modern projects, especially when writing mode or overflow control matters.
Wrap Up
Conclusion
The max-block-size property is a useful tool for controlling the maximum size of block-level elements along the block axis.
By setting appropriate maximum sizes and pairing them with overflow, you can ensure elements fit well within your layout constraints. Experiment with different values to achieve a responsive and well-structured design.
Pair max-block-size with overflow: auto when content may exceed the cap
Use it alongside block-size and min-block-size for full logical sizing control
Prefer logical max properties in layouts that may change writing mode
Use viewport units like 50vh for responsive maximum heights
Test scroll behavior on touch devices when capping content areas
❌ Don’t
Cap block size without deciding what happens to overflow content
Assume max-block-size always equals max-height in every layout
Confuse max-block-size with block-size — one sets a ceiling, the other sets preferred size
Expect percentages to work when the parent block size is undefined
Skip fallbacks if you must support very old browsers
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about max-block-size
Use these points when capping logical block dimensions.
5
Core concepts
📏01
Maximum Cap
Sets the ceiling.
Purpose
📝02
none Default
No maximum limit.
Default
🔄03
Writing Mode
Follows block axis.
Context
📈04
Overflow Pair
Scroll when capped.
UX
🛠05
Logical Trio
block, min, max.
System
❓ Frequently Asked Questions
The max-block-size property sets the maximum size of an element along the block axis. In horizontal writing, that usually caps height. The element can shrink below this value but cannot grow beyond it.
The default value is none, which means there is no maximum block-size constraint and the element can grow with its content and other sizing rules.
max-height always limits vertical size. max-block-size follows the writing mode, so it limits height in horizontal writing and width in vertical writing.
Common values include none, length units like px and rem, percentages, max-content, min-content, and fit-content.
Yes, when content may exceed the maximum block size. Use overflow: auto or overflow-y: auto to add scrolling instead of letting content spill out unexpectedly.