v150 · CSS · Typography
CSS fit-width text
The text-fit property scales a text element's font size so the text exactly fills its container's inline axis — text-fit: scale-down only shrinks, text-fit: balance also expands. No JavaScript, no vw hacks, no clamp() approximations.
concepts
-
Headline Scaler
A set of headlines at varying container widths — all using
text-fit: scale-downto prevent overflow without a single media query or font-size calculation. -
Caption Fitter
Image cards with captions of different lengths —
text-fit: balancescales each caption to exactly span the card width, aligning the visual weight of text and image. -
Logo Lockup
Brand name + tagline pair —
text-fit: balanceon the brand fills the container,text-fit: scale-downon the tagline prevents overflow. Drag the resize box or use the width slider to see both scale together. -
Pull Quote Scaler
Editorial pull quotes that exactly fill their column — short quotes expand, long quotes scale down. Four quote lengths + a toggle let you compare
text-fit: balanceagainst a fixedfont-sizeacross any container width. -
Banner Builder
Build a promotional banner where the headline responds to its container using the current
text-fitproperty. Edit the copy, choose a theme, switch betweengrow,shrink, andnone, then resize the preview to see native fitting or the labelled fallback path. -
API Console
Mutate every
text-fitinput — value (none/scale-down/balance), base font size, container width, font family and weight,white-space— and inspectgetComputedStyle()live. Feature-detection badges show which values Chrome supports in this build. Generates a copyable CSS snippet. -
Migration Diff
Four old patterns (viewport units,
clamp(), JavaScript fitText loops,transform: scaleX()) compared againsttext-fit. Toggle between old and new in a live resizable preview and read why the native approach is more accurate, causes no layout shift, and requires zero script.
why it shipped
Fitting text to a container has historically required JavaScript (measuring element widths, adjusting font-size in a loop) or rough approximations like font-size: 4vw or clamp() that only work for one specific breakpoint. The CSS text-fit property solves this natively: the browser measures the text, computes the exact scale factor, and applies it during layout — perfectly responsive with no script. scale-down only reduces the font size when text overflows (preventing truncation), while balance also expands short text to fill available space (useful for pull quotes and hero headings).