line-break CSS property
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since July 2020.
The line-break CSS property sets how to break lines of Chinese, Japanese, or Korean (CJK) text when working with punctuation and symbols.
Try it
line-break: auto;
line-break: anywhere;
line-break: normal;
line-break: loose;
<section id="default-example">
<p id="example-element">
ãã®å«è¶åºã¯ããã¤ã§ãã³ã¼ãã¼ã®é¦ããæ¼ããã¦ãã¾ãã<br />彼女ã¯ãã®å«è¶åºã§åãã¦ãçã
ã¨å®åãã¤ãã¦ããã¾ããã<br />ä»ã§ã¯ç¥ã人ãç¥ããå人ã§ãã
</p>
</section>
#example-element {
font-family: "Yu Gothic", "YuGothic", "Meiryo", "ï¼ï¼³ ã´ã·ãã¯", sans-serif;
border: 2px dashed #999999;
text-align: left;
width: 240px;
font-size: 16px;
}
Syntax
/* Keyword values */
line-break: auto;
line-break: loose;
line-break: normal;
line-break: strict;
line-break: anywhere;
/* Global values */
line-break: inherit;
line-break: initial;
line-break: revert;
line-break: revert-layer;
line-break: unset;
Values
auto-
Break text using the default line break rule.
loose-
Break text using the least restrictive line break rule. Typically used for short lines, such as in newspapers.
normal-
Break text using the most common line break rule.
strict-
Break text using the most stringent line break rule.
anywhere-
There is a soft wrap opportunity around every typographic character unit, including around any punctuation character or preserved white spaces, or in the middle of words, disregarding any prohibition against line breaks, even those introduced by characters with the GL, WJ, or ZWJ character class or mandated by the
word-breakproperty. The different wrapping opportunities must not be prioritized. Hyphenation is not applied.
Formal definition
| Initial value | auto |
|---|---|
| Applies to | all elements |
| Inherited | yes |
| Computed value | as specified |
| Animation type | discrete |
Formal syntax
line-break =
auto |
loose |
normal |
strict |
anywhere
Examples
>Setting text wrapping
See whether the text is wrapped before "ã ", "ã" and "ã".
HTML
<div lang="ja">
<p class="wrap-box auto">
auto:<br />ããã¯æ¹ã®ã»ã¨ãã§æ¨ã
ãè¼ãã¦ããã<br />ãã®æ¯è²ã«ãç¾ãããªãã¨æããã¤ã¶ãããã
</p>
<p class="wrap-box loose">
loose:<br />ããã¯æ¹ã®ã»ã¨ãã§æ¨ã
ãè¼ãã¦ããã<br />ãã®æ¯è²ã«ãç¾ãããªãã¨æããã¤ã¶ãããã
</p>
<p class="wrap-box normal">
normal:<br />ããã¯æ¹ã®ã»ã¨ãã§æ¨ã
ãè¼ãã¦ããã<br />ãã®æ¯è²ã«ãç¾ãããªãã¨æããã¤ã¶ãããã
</p>
<p class="wrap-box strict">
strict:<br />ããã¯æ¹ã®ã»ã¨ãã§æ¨ã
ãè¼ãã¦ããã<br />ãã®æ¯è²ã«ãç¾ãããªãã¨æããã¤ã¶ãããã
</p>
<p class="wrap-box anywhere">
anywhere:<br />ããã¯æ¹ã®ã»ã¨ãã§æ¨ã
ãè¼ãã¦ããã<br />ãã®æ¯è²ã«ãç¾ãããªãã¨æããã¤ã¶ãããã
</p>
</div>
CSS
.wrap-box {
width: 10em;
margin: 0.5em;
white-space: normal;
vertical-align: top;
display: inline-block;
}
.auto {
line-break: auto;
}
.loose {
line-break: loose;
}
.normal {
line-break: normal;
}
.strict {
line-break: strict;
}
.anywhere {
line-break: anywhere;
}
Result
Specifications
| Specification |
|---|
| CSS Text Module Level 3 > # line-break-property > |
Browser compatibility
See also
- CSS and international text on W3C