Home CSS Properties inline-size CSS inline-size Property Definition
Definition and Usage The inline-size property sets the size of an element along the inline axis . In a horizontal writing mode it behaves like width . In a vertical writing mode it behaves like height .
It is not inherited. The initial value is auto. Pair it with block-size for the other axis, and with writing-mode when text direction changes.
Logical property. Prefer inline-size over width when a layout must stay correct for both horizontal and vertical writing modes.
Syntax
CSS Syntax inline-size: auto | <length> | <percentage> | min-content | max-content | fit-content | initial | inherit ;
Values match width / height. Newer keywords like stretch have limited support.
Values
Property Values Value Description Try it autoDefault. Browser sizes the box from content Try it<length>Fixed size such as 200px, 12rem, or 40vw Try it<percentage>Percent of the containing block’s inline size Try itwith writing-mode In vertical mode, inline-size maps to physical height Try itinitialResets to auto Try itinheritTakes the parent’s inline-size Try it
Approach
How to Use inline-size Think in writing-mode terms: size the inline axis, not “always left–right.”
Use inline-size where you would reach for width in a horizontal layout. Pick auto, a length, or a percentage of the containing block. Add min-inline-size / max-inline-size when you need floors or caps. Test with writing-mode if the page may switch to vertical text. Piece Required? Role Block or sized box Yes Same applicability rules as width inline-size valueYes auto, length, percentage, or keywordContaining block size For % Percentage uses the parent’s inline size writing-modeOptional Chooses whether inline maps to width or height
Try it
Live Preview Change inline-size on the sample box. In the default horizontal mode, this acts like width.
Code
CSS Examples Each snippet focuses on inline-size. Use Try It Yourself for a live editor.
1. Length 2. Percentage 3. Writing mode Example 1 — Fixed Length Set an exact inline size. In horizontal mode this is like width.
<style>
div {
inline-size: 200px;
}
</style>
<div>200px inline</div> How It Works Pick a length. 200px sets the inline-axis size.Horizontal mode. With default writing mode, that size is the physical width.Content may wrap. Text wraps inside the fixed inline size.Other units work. Try rem, em, or vw the same way.Example 2 — Percentage of Parent Size a child as half of the parent’s inline size.
<style>
.parent {
inline-size: 320px;
}
.child {
inline-size: 50%;
}
</style>
<div class="parent">
<div class="child">Half of parent</div>
</div> How It Works Give the parent an inline size. 320px defines the containing block.Use a percentage on the child. 50% resolves to 160px here.Axis matters. The percent uses the parent’s inline size, not block size.Same idea as width %. In horizontal mode the math matches width: 50%.Example 3 — Vertical Writing Mode With vertical text, inline-size maps to physical height.
<style>
div {
writing-mode: vertical-rl;
inline-size: 120px;
}
</style>
<div>Inline axis</div> How It Works Set vertical writing. writing-mode: vertical-rl rotates the axes.Inline becomes vertical. Text flows top-to-bottom; the inline axis is now vertical.inline-size follows. 120px controls physical height, not width.Why logical wins. One rule keeps sizing correct when writing mode changes. Edge Cases & Pitfalls Most confusion comes from mixing logical and physical sizing.
map Not always the same as width In vertical writing modes, inline-size maps to height. Do not assume it always means left–right size.
conflict Mixing with width can conflict Setting both width and inline-size on the same element can produce unexpected results. Prefer one system.
percent Percentage uses inline containing size Percentages resolve against the containing block’s inline size. In vertical mode that parent measure is physical height.
limits min- / max-inline-size overrideThose properties can stop a box from shrinking or growing past a limit, just like min-width / max-width.
box box-sizing still appliesWith border-box, padding and border count inside the size. With content-box, they add outside it.
Compatibility
Browser Support inline-size is a browser layout property . Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
inline-size Widely available across modern browsers since ~2020. Same value set as width/height; stretch remains limited.
Google Chrome 57+
Full
Mozilla Firefox 41+
Full
Apple Safari 12.1+
Full
Microsoft Edge 79+
Full
Opera 44+
Full
Samsung Internet 7.0+
Full
Internet Explorer No
None inline-size Widely supported
Bottom line: Safe for modern sites. Prefer logical sizing when writing-mode flexibility matters. Skip Internet Explorer.
Remember
Key Takeaways Role: size the inline axis — width in horizontal mode, height in vertical mode.
Common values: auto, lengths, and percentages (same as width).
Initial value: auto. Not inherited.
Tip: use with block-size for fully logical box sizing.
One line: inline-size is the logical version of width — it follows the writing mode’s inline axis.
Frequently Asked Questions What does the CSS inline-size property do? It sets the size of an element along the inline axis. In horizontal writing modes it maps to width; in vertical writing modes it maps to height.
What is the default value of inline-size? The initial value is auto. The browser sizes the box from content and layout rules.
What is the difference between inline-size and width? width always controls the horizontal size. inline-size follows writing-mode, so it adapts when text runs vertically.
When should I use inline-size instead of width? Use it when you want logical sizing that stays correct across horizontal and vertical writing modes.
Is inline-size inherited? No. Percentages resolve against the inline size of the containing block.
Which browsers support inline-size? It is Baseline and widely available across modern browsers since about 2020. It is a browser layout property, not a Node.js feature.
Next: inset Learn the shorthand for top, right, bottom, and left offsets.
inset tutorial → About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion