Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

max-inline-size — maximum size along the inline axis

max-inline-size limits an element's size along its inline axis. It corresponds to max-width in horizontal writing and max-height in vertical writing, so the constraint adapts to writing-mode.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

max-inline-size: none | <length-percentage [0,∞]> | min-content | max-content | fit-content | stretch | <calc-size()> | <anchor-size()>;
<calc-size()> = calc-size( <calc-size-basis>, <calc-sum> )
<anchor-size()> = anchor-size( [ <anchor-name> || <anchor-size> ]? , <length-percentage>? )
<anchor-name> = <dashed-ident>
<anchor-size> = width | height | block | inline | self-block | self-inline
/* Chromium 152: supports anchor-size() for anchor-positioned sizing and also accepts CSS-wide keywords; fit-content(...) is not supported for this property. */

max-inline-size sets an upper constraint on an element's inline-axis size, not its target size. With writing-mode: horizontal-tb, it corresponds to max-width; with writing-mode: vertical-rl, it corresponds to max-height. Its initial value is none, and it is not inherited.

Use a nonnegative length or percentage, min-content, max-content, or the bare fit-content keyword. Chromium 152 supports the keyword but not the fit-content(...) function for this property. A percentage refers to the corresponding dimension of the containing block; an indefinite dimension can complicate its resolution. none removes this constraint.

The constraint can reduce the size requested by inline-size, but a larger minimum from min-inline-size takes precedence. For lengths and percentages, box-sizing determines whether the constraint targets the content box or border box. The constraint alone does not clip overflowing content.

In the example, inline-size: 240px is capped at 120px. Because of box-sizing: border-box, measurements include padding and borders. Changing writing-mode moves the constraint from width to height. The example demonstrates a pixel limit, not the keyword or the function.

Examples

<!doctype html>
<meta charset="utf-8">
<title>max-inline-size</title>
<style>
  .box {
    box-sizing: border-box;
    inline-size: 240px;
    max-inline-size: 120px;
    block-size: 40px;
    padding: 4px;
    border: 2px solid;
    writing-mode: horizontal-tb;
  }
  .vertical { writing-mode: vertical-rl; }
</style>
<div class="box"></div>
<div class="box vertical"></div>

Result

Expected border-box dimensions in CSS pixels:
.box: 120 × 40
.box.vertical: 40 × 120

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources