CSS max-block-size Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Layout & Sizing

What You’ll Learn

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.

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.

📝 Syntax

Write max-block-size with a length, percentage, sizing keyword, or none:

syntax.css
element {
  max-block-size: length | max-content | min-content | fit-content | none | initial | inherit;
}

Basic Example

max-block-size.css
.box {
  max-block-size: 400px;
  overflow: auto;
  background-color: #e2e8f0;
}

Syntax Rules

  • 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.

⚡ Quick Reference

QuestionAnswer
Initial valuenone
Applies toAll elements
InheritedNo
AnimatableNo
Common useScrollable panels, capped cards, responsive max heights in logical layouts

🎯 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.

💎 Property Values

These are the most common values you will use with max-block-size.

ValueExampleMeaning
nonemax-block-size: none;No maximum block-size constraint (default)
Lengthmax-block-size: 300px;Defines a fixed maximum size using units like px or rem
Percentagemax-block-size: 50%;Maximum size relative to the containing block’s block dimension
max-contentmax-block-size: max-content;Caps size at the content’s intrinsic maximum block size
min-contentmax-block-size: min-content;Caps size at the content’s intrinsic minimum block size
fit-contentmax-block-size: fit-content;Allows growth to fit content without exceeding available space
Horizontal writing → max-block-size = max-height Vertical writing → max-block-size = max-width
400px

A fixed maximum block size in pixels or other length units.

Most common for scrollable panels.

50%

Cannot exceed half of the parent container’s block size.

Useful in responsive layouts.

none

No upper limit — the element can grow freely.

Default browser behavior.

fit-content

Maximum follows content while respecting available space.

Good for flexible components.

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.

max-block-size vs max-height

PropertyAxisBest for
max-block-sizeBlock axis (depends on writing mode)International layouts, reusable components, logical sizing systems
max-heightAlways verticalSimple pages with fixed max heights in horizontal writing
block-sizeBlock axis (depends on writing mode)Preferred block dimension paired with max/min limits
heightAlways verticalSimple fixed-height boxes in horizontal writing

👀 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.

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>

<div class="box">
  Long paragraph content goes here…
</div>
Try It Yourself

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.

max-block-size-scroll.html
<style>
  .panel {
    max-block-size: 150px;
    overflow-y: auto;
    padding: 1rem;
    background: #dbeafe;
  }
</style>

<div class="panel">
  Scrollable panel content…
</div>
Try It Yourself

How It Works

A 150px maximum keeps the panel compact. Shorter content stays smaller; longer content scrolls inside the capped area.

📈 Responsive Maximums

Use viewport and comparison techniques so max caps adapt across screen sizes.

Example 3 — Viewport-Relative Cap (50vh)

Limit block size relative to the viewport so tall content never dominates small screens.

max-block-size-vh.css
.hero-card {
  max-block-size: 50vh;
  overflow: auto;
  padding: 1.5rem;
}
Try It Yourself

How It Works

50vh means half the viewport height along the block axis in horizontal writing. The cap shrinks on short screens and grows on tall ones.

Example 4 — Compare No Max vs Two Caps

See how the same long text behaves with no limit, a tight cap, and a roomier cap.

max-block-size-compare.css
.none { max-block-size: none; }
.sm { max-block-size: 120px; overflow: auto; }
.md { max-block-size: 240px; overflow: auto; }
Try It Yourself

How It Works

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.

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 Explorer No support · Use max-height or max-width instead
None
max-block-size property 96% supported

Bottom line: Use max-block-size confidently in modern projects, especially when writing mode or overflow control matters.

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.

💡 Best Practices

✅ Do

  • 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

Key Takeaways

Knowledge Unlocked

Five things to remember about max-block-size

Use these points when capping logical block dimensions.

5
Core concepts
📝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.

Practice in the Live Editor

Open the HTML editor, set max-block-size, and preview capped scrollable content instantly.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful