CSS max-inline-size Property

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

What You’ll Learn

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.

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.

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

Basic Example

max-inline-size.css
p {
  max-inline-size: 300px;
  border: 1px solid #ccc;
  padding: 10px;
}

Syntax Rules

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

⚡ Quick Reference

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

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

💎 Property Values

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

ValueExampleMeaning
lengthmax-inline-size: 500px;A specific length value such as px, em, rem, or vw
percentagemax-inline-size: 80%;A percentage relative to the containing block’s inline size
automax-inline-size: auto;Uses intrinsic size or other layout constraints
nonemax-inline-size: none;No maximum size constraint (default)
Horizontal writing → max-inline-size = max-width Vertical writing → max-inline-size = max-height
300px

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

Most common for readable text columns.

50%

Cannot exceed half of the parent container’s inline 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 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.

max-inline-size vs max-width

PropertyAxisBest for
max-inline-sizeInline axis (depends on writing mode)International layouts, reusable components, logical sizing systems
max-widthAlways horizontal (physical width)Simple layouts with fixed maximum widths in horizontal writing
inline-sizeInline axis (depends on writing mode)Preferred inline 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-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.

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>
Try It Yourself

How It Works

In horizontal writing, max-inline-size: 300px caps width. The paragraph can be narrower but never wider than 300px.

Example 2 — Readable Column (20rem)

Use rem units for a typography-friendly maximum inline size on article content.

max-inline-size-column.css
.article {
  max-inline-size: 20rem;
  margin-inline: auto;
  padding: 1rem;
  background: #dbeafe;
}
Try It Yourself

How It Works

20rem scales with root font size, so the cap stays proportional when users change text settings.

📈 Responsive Maximums

Use viewport units and comparisons so inline caps adapt across screen sizes.

Example 3 — Viewport-Relative Cap (80vw)

Limit inline size relative to the viewport so content never spans the full window on ultra-wide monitors.

max-inline-size-vw.css
.card {
  max-inline-size: 80vw;
  margin-inline: auto;
  padding: 1.5rem;
}
Try It Yourself

How It Works

80vw means 80% of the viewport width along the inline axis in horizontal writing.

Example 4 — Compare No Max vs Two Caps

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

max-inline-size-compare.css
.none { max-inline-size: none; }
.sm { max-inline-size: 200px; }
.md { max-inline-size: 400px; }
Try It Yourself

How It Works

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.

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

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

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.

💡 Best Practices

✅ Do

  • 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

Key Takeaways

Knowledge Unlocked

Five things to remember about max-inline-size

Use these points when capping logical inline dimensions.

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

Practice in the Live Editor

Open the HTML editor, set max-inline-size, and preview capped inline width 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