← Back to release summary

CSS `text-fit` property

Category
CSS
Type
New or changed feature
Status
Proposed (Chrome Proposed)
Intent stage
None

Summary

Scales the font size of text nodes to perfectly fit the width of its containing box. This property allows developers to ensure headlines or dynamic content fill the available horizontal space without manual font-size calculations or complex JavaScript workarounds. It provides a robust, CSS-native solution for responsive typography that maintains visual alignment across different screen sizes and varying text lengths.

Motivation

In text layout, web authors want to align the lines with both ends of the container, but web authors want to achieve this by adjusting the font size instead of justification. Without this feature, the only option is to manually adjust the font size through trial and error or using JavaScript. Web authors want to fit the text into a container of a specific size without it overflowing. For example, if the container width is narrow and a long word inevitably overflows the container, web authors want to reduce the font size to make it fit within the container. Web authors want to avoid text overflowing the container due to unexpectedly long words used in text translations or when end-users provide arbitrary text.

Standards & signals

Explainers: https://github.com/explainers-by-googlers/css-fit-text/blob/main/README.md

View on chromestatus.com