Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

CSS property `line-break`

`line-break` selects permitted line-breaking opportunities, especially around CJK characters and punctuation.

Version: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review

Syntax

auto | loose | normal | strict | anywhere

line-break selects permitted line-breaking opportunities, especially around CJK characters and punctuation.

The example compares a narrow box under strict and anywhere; the latter can split an otherwise unbreakable token across six lines.

Grammar: auto | loose | normal | strict | anywhere.

The property is inherited, and the result depends on the element’s language and script. Differences among loose, normal, and strict mainly concern CJK rules; anywhere deliberately adds many more break opportunities.

Examples

<!doctype html>
<html lang="en"><meta charset="utf-8"><title>line-break behavior</title>
<body><div id="probe">ABCDEFGHIJKLMN</div><pre id="result"></pre><script>
const probe=document.querySelector('#probe');probe.lang='en';probe.style.cssText='display:inline-block;width:32px;font:16px/20px sans-serif;line-break:strict';
const strict=Math.round(probe.getBoundingClientRect().height);probe.style.lineBreak='anywhere';const anywhere=Math.round(probe.getBoundingClientRect().height);
document.querySelector('#result').textContent='height='+strict+'->'+anywhere+'; lines='+strict/20+'->'+anywhere/20+'; computed='+getComputedStyle(probe).lineBreak;
</script></body></html>

Result

height=20->120; lines=1->6; computed=anywhere

The example was executed locally in an isolated, network-free Chrome session; the result comes from the browser CSS API.

Sources