CSS inline-size Property

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

What You’ll Learn

The inline-size property sets an element’s size along the inline axis. It is a logical alternative to width that adapts when writing direction or mode changes.

01

Logical Size

Inline axis.

02

auto

Default value.

03

Writing Mode

Adapts axis.

04

Percentages

Relative size.

05

fit-content

Content-based.

06

Responsive

Flexible layouts.

Introduction

The inline-size property in CSS defines the horizontal or vertical size of an element, depending on the element’s writing mode. In horizontal writing modes, it sets the width. In vertical writing modes, it sets the height along the text flow direction.

This property is useful for responsive designs that must adapt to different writing modes, languages, and screen orientations without rewriting layout rules.

Definition and Usage

Apply inline-size to block containers, cards, columns, and any element where you would normally use width in a horizontal layout. Pair it with related logical properties such as block-size, margin-inline, and padding-inline for consistent logical layouts.

💡
Beginner Tip

In everyday horizontal English pages, inline-size: 200px behaves like width: 200px. The advantage appears when writing mode changes.

📝 Syntax

The syntax for the inline-size property is similar to other sizing properties:

syntax.css
element {
  inline-size: value;
}

Here, value can be a length, percentage, or keywords such as auto, max-content, min-content, and fit-content.

Basic Example

inline-size-basic.css
.box {
  inline-size: 50%;
  background-color: lightblue;
  padding: 10px;
}
inline-size: auto; inline-size: 200px; inline-size: 50%; inline-size: fit-content;

Default Value

The default value of the inline-size property is auto, which means the size is determined by the content and other layout properties of the element.

Syntax Rules

  • Maps to width in horizontal top-to-bottom writing modes.
  • Maps to height in vertical writing modes such as vertical-rl.
  • The property is not inherited.
  • Accepts the same value types as width in most cases.
  • Percentage values depend on the containing block’s inline size.

⚡ Quick Reference

QuestionAnswer
Initial valueauto
Applies toAll elements except non-replaced inline elements, table rows, and row groups
InheritedNo
AnimatableYes, as a length
Horizontal writing modeBehaves like width

💎 Property Values

ValueDescription
lengthA fixed size such as 50px, 10rem, or 20em.
percentageA size relative to the containing block’s inline size, such as 50%.
autoThe browser calculates the inline size from content and layout.
max-contentThe largest inline size the content can take without wrapping.
min-contentThe smallest inline size the content can take without overflowing.
fit-contentClamps the inline size between min-content and the available space.

Writing Modes and the Inline Axis

Logical properties follow the document’s writing mode instead of fixed physical directions:

  • Horizontal mode (writing-mode: horizontal-tb) — inline axis runs left to right; inline-size controls width.
  • Vertical mode (writing-mode: vertical-rl) — inline axis runs top to bottom; inline-size controls height along the text flow.
  • Related propertyblock-size controls the size along the block axis (the opposite dimension).
🔄
inline-size vs width

Use width when you always mean horizontal size. Use inline-size when layouts should adapt to writing mode changes automatically.

👀 Live Preview

A box at inline-size: 50% in horizontal mode, and vertical text with a fixed inline size:

50% inline size
Vertical inline axis

Examples Gallery

Set a percentage inline size, fixed pixels, vertical writing mode behavior, and compare auto with fit-content.

🔢 Inline Sizing Basics

Start with the reference example — an element sized to half its container’s inline dimension.

Example 1 — Percentage Inline Size

Set a box to 50% of its container’s inline size.

inline-size-percent.css
.box {
  inline-size: 50%;
  background-color: lightblue;
  padding: 10px;
  text-align: center;
}
Try It Yourself

How It Works

In horizontal writing mode, inline-size: 50% makes the box half as wide as its containing block.

Example 2 — Fixed Pixel Inline Size

Use a fixed length when you need a predictable inline dimension.

inline-size-px.css
.box {
  inline-size: 200px;
  background-color: #dbeafe;
  padding: 1rem;
}
Try It Yourself

How It Works

inline-size: 200px sets a fixed inline dimension, equivalent to width: 200px in normal horizontal layouts.

📈 Writing Modes & Keywords

See how inline-size adapts in vertical writing mode and with content-based sizing keywords.

Example 3 — Vertical Writing Mode

In vertical text flow, inline-size controls the vertical dimension instead of width.

inline-size-vertical.css
.vertical-box {
  writing-mode: vertical-rl;
  inline-size: 120px;
  background-color: #ede9fe;
  padding: 1rem;
}
Try It Yourself

How It Works

With writing-mode: vertical-rl, the inline axis rotates. The same inline-size rule now limits vertical space along the text flow.

Example 4 — auto vs fit-content

Compare default sizing against content-fit inline sizing on short text blocks.

inline-size-fit.css
.auto { inline-size: auto; }
.fit { inline-size: fit-content; }
Try It Yourself

How It Works

fit-content sizes the element to its content while respecting available space, useful for buttons, tags, and inline cards.

♿ Accessibility

  • Do not shrink text containers too narrowly — Small inline sizes can hurt readability.
  • Support zoom and reflow — Fixed inline sizes should not block text enlargement.
  • Writing mode changes affect layout — Test vertical layouts for logical reading order.
  • Keep touch targets wide enough — Buttons sized with fit-content still need adequate padding.
  • Maintain logical DOM order — Logical sizing does not replace semantic structure.

🧠 How inline-size Works

1

Writing mode defines the inline axis

Horizontal or vertical text flow determines whether inline-size maps to width or height.

Writing mode
2

You set an inline-size value

Choose auto, a length, percentage, or keyword like fit-content.

CSS rule
3

The browser resolves the dimension

The computed size is applied along the inline axis of the element’s containing block.

Layout
=

Logical inline sizing

The element gets the correct dimension for its writing mode and layout context.

🖥 Browser Compatibility

The inline-size property is supported in modern browsers including Chrome 57+, Firefox 41+, Safari 12.1+, and Edge 79+.

Baseline · Modern browsers

Logical sizing in today’s browsers

All major browsers support inline-size as part of the CSS Logical Properties module.

95% Modern browser support
Google Chrome 57+ · Desktop & Mobile
Full support
Mozilla Firefox 41+ · Desktop & Mobile
Full support
Apple Safari 12.1+ · macOS & iOS
Full support
Microsoft Edge 79+ · Chromium
Full support
Opera 44+ · Modern versions
Full support
inline-size property 95% supported

Bottom line: Safe to use in modern projects. For older browsers, width remains a reliable fallback.

🎉 Conclusion

The inline-size property is a versatile tool for creating flexible, writing-mode-aware layouts. By understanding how it maps to the inline axis, you can build responsive designs that adapt to different languages and orientations.

For beginners, start with inline-size wherever you would use width in horizontal layouts, then explore vertical writing modes to see the logical advantage.

💡 Best Practices

✅ Do

  • Use inline-size in multilingual or logical layouts
  • Pair with block-size for full logical sizing
  • Test with writing-mode: vertical-rl
  • Use fit-content for tags and compact UI chips
  • Provide width fallback only when needed for legacy support

❌ Don’t

  • Mix physical and logical sizing without a reason
  • Assume percentages work without a defined containing block
  • Force narrow inline sizes on long paragraphs
  • Forget padding and borders in total space calculations
  • Change writing mode without checking reading order

Key Takeaways

Knowledge Unlocked

Five things to remember about inline-size

Use these points when building logical layouts.

5
Core concepts
auto 02

Default auto

Content-based.

Default
width 03

Like width

Horizontal mode.

Syntax
vertical 04

Writing mode

Rotates axis.

Pattern
fit 05

Keywords

fit-content.

Values

❓ Frequently Asked Questions

inline-size sets the size of an element along the inline axis. In horizontal writing modes it acts like width; in vertical writing modes it acts like height.
The default is auto, which lets the browser calculate size from content and other layout properties.
width always controls horizontal size. inline-size follows the writing mode, so it adapts to horizontal or vertical text direction.
Use inline-size when building layouts that must support multiple writing modes or logical property patterns.
No. inline-size is not inherited, but percentage values are calculated relative to the containing block.

Practice in the Live Editor

Open the HTML editor, set inline-size values, and switch writing-mode to see the inline axis change.

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