CKTIS / CSS
text-fit — scaling text to a line
The experimental text-fit property scales text after line wrapping. It selects growth or shrinkage, controls whether lines share a scale factor, and accepts a percentage limit.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
text-fit: [ none | grow | shrink ] [ consistent | per-line | per-line-all ]? <percentage>?text-fit applies to block containers, inherits, and initially equals none. grow enlarges text; shrink reduces it; none disables scaling.
Default consistent shares one factor. per-line scales lines separately. It skips the last line and lines ending in a forced break only with grow, not with shrink. per-line-all includes those lines even with grow.
Percentages limit scaling: with grow, values ≥100% set a maximum; with shrink, 0–100% sets a minimum. Other values or omission impose no limit.
Scaling follows wrapping and leaves computed font-size unchanged. This is a CSSWG draft, not a support guarantee. Fitting can interfere with user text enlargement.
Examples
<!doctype html>
<meta charset="utf-8">
<title>text-fit</title>
<style>
.sample {
inline-size: 240px;
font: 20px monospace;
white-space: nowrap;
border: 1px solid;
}
.fitted { text-fit: grow consistent 200%; }
</style>
<p class="sample">MMMM</p>
<p class="sample fitted">MMMM</p>Result
With the specified behavior implemented, the second sample grows, capped at 200%; it need not fill the box. Without support, both samples retain their original text size.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.