0Support

CSS text-fit playground

Explore text-fit with none, grow, and shrink, the consistent, per-line, and per-line-all modes, and an optional percentage that limits the scaling factor.

Ask AI

CSS text-fit playground

Response generated with openai/gpt-5.4-nano. AI can make mistakes. Always review the result.

Design headlines that fill every line without JavaScript calculations.

Your browser does not support text-fit yet. The preview keeps the original font-size, while the generated code preserves the property.

HTML
<h2 class="text-fit-sample">
  Design headlines that fill every line without JavaScript calculations.
</h2>
Tailwind CSS
Some classes with arbitrary values can be replaced by native classes, depending on the value and your Tailwind CSS configuration.
<h2 class="w-[520px] max-w-full font-extrabold text-[32px] leading-[1.05] whitespace-normal [text-fit:grow_consistent_180%]">
  Design headlines that fill every line without JavaScript calculations.
</h2>
CSS
.text-fit-sample {
  inline-size: 520px;
  max-inline-size: 100%;
  font-family: system-ui, sans-serif;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.05;
  white-space: normal;
  text-fit: grow consistent 180%;
}