Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

text-wrap-style — text wrapping strategy

The text-wrap-style property controls how line breaks are selected when text wrapping is allowed.

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

Syntax

text-wrap-style: auto | balance | stable | pretty | avoid-short-last-line;

text-wrap-style selects existing break opportunities rather than creating new ones. It is inherited and initially auto. text-wrap-mode controls whether wrapping is allowed; the text-wrap shorthand sets both properties.

auto leaves the algorithm to the browser; balance evens out line lengths; stable ignores subsequent lines when deciding breaks, limiting changes during editing. pretty favors quality over speed; avoid-short-last-line focuses on avoiding an excessively short final line.

Algorithms are browser-dependent. Above ten lines, balance may behave as auto. The specification is a draft: its syntax does not guarantee support in the target browser.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>text-wrap-style comparison</title>
<style>
  .sample {
    inline-size: 20ch;
    font: 20px/1.5 monospace;
    text-wrap-mode: wrap;
    text-wrap-style: auto;
    border: 1px solid;
  }
  .balanced { text-wrap-style: balance; }
</style>
<p>auto</p>
<div class="sample">AAAA BBBB CCCC DDDD EEEE</div>
<p>balance</p>
<div class="sample balanced">AAAA BBBB CCCC DDDD EEEE</div>
</html>

Result

Two bordered text blocks labeled auto and balance. Both allow wrapping; balance requests more even line lengths. Exact line breaks are browser-dependent.

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