CSS word-break Property
The CSS word-break property controls where the browser is allowed to break lines within words when text reaches the edge of its container.
It is useful for controlling how long words, mixed-language text, and content written in different writing systems wrap across lines. The property can preserve normal word boundaries, allow breaks between individual characters, or restrict certain line breaks in Chinese, Japanese, and Korean text.
On This Page
Syntax
The word-break property accepts a keyword that determines how line-breaking opportunities are handled within text.
selector {
word-break: normal | break-all | keep-all | auto-phrase | break-word;
}
Common declarations include:
p {
word-break: normal;
}
.long-text {
word-break: break-all;
}
.korean-text {
word-break: keep-all;
}
.phrase-text {
word-break: auto-phrase;
}
The break-word value is also supported for compatibility, although it is deprecated in favor of more explicit wrapping behavior.
Property Values
| Value | Description |
|---|---|
normal |
Uses the browser's default line-breaking rules for the language and writing system. This is the initial value. |
break-all |
Allows breaks between characters in non-CJK text to prevent overflow, even when this splits words. It does not override normal CJK line-breaking restrictions in the same way. |
keep-all |
Prevents breaks between Chinese, Japanese, and Korean characters except where the normal rules allow them, such as at spaces. |
auto-phrase |
Uses language-aware phrase analysis to reduce inappropriate breaks within natural phrases. Browser support is limited. |
break-word |
Provides behavior equivalent to overflow-wrap: anywhere combined with word-break: normal. This value is deprecated but remains supported. |
initial |
Resets the property to its initial value, normal. |
inherit |
Uses the computed word-break value of the parent element. |
unset |
Uses the inherited value because word-break is an inherited property. |
revert |
Reverts the property according to the CSS cascade. |
revert-layer |
Reverts the property to the value established by an earlier cascade layer. |
How It Works
When text is longer than the available width of its container, the browser looks for suitable places to move part of the text onto the next line.
With the default normal value, the browser follows language-specific line-breaking rules. English text typically wraps at spaces and other permitted break points, while languages such as Chinese and Japanese allow different breaking opportunities.
The word-break property changes these rules by permitting or restricting breaks within words and character sequences.
.text-box {
width: 180px;
word-break: break-all;
}
In this example, a long English word can be split between characters when necessary to fit inside the 180-pixel container.
The property does not insert actual spaces or change the underlying text. It only affects how the browser lays out the text across lines.
normal vs. break-all
The most noticeable difference is between normal and break-all.
Using normal
The normal value follows ordinary word boundaries and language-specific line-breaking rules.
.normal-text {
width: 160px;
word-break: normal;
}
A long unbroken English word may extend beyond the container if no other wrapping rules allow it to break.
Using break-all
The break-all value allows the browser to split non-CJK words between characters when needed.
.break-all-text {
width: 160px;
word-break: break-all;
}
This can prevent overflow, but it may make ordinary paragraphs harder to read because words can be divided at unexpected positions.
For English text, overflow-wrap: anywhere is often a better choice when the goal is to handle unusually long words without changing normal wrapping behavior throughout the paragraph.
Using keep-all
The keep-all value is particularly useful for controlling line breaks in Chinese, Japanese, and Korean text.
Under normal rules, these writing systems may allow line breaks between characters without spaces. The keep-all value restricts those opportunities.
.korean-paragraph {
word-break: keep-all;
}
For Korean text, this can help keep space-separated word groups together. For Chinese and Japanese text, it can prevent breaks between characters that would otherwise be permitted.
Because the results depend on the writing system and language, use the appropriate HTML lang attribute when working with multilingual content.
<p lang="ko" class="korean-paragraph">
안녕하세요. CSS 줄 바꿈 예제입니다.
</p>
Using auto-phrase
The auto-phrase value allows the browser to analyze text and reduce line breaks that would divide natural phrases.
.japanese-text {
word-break: auto-phrase;
}
This value is intended to improve the readability of text in writing systems where phrase boundaries are not always marked by spaces.
Unlike keep-all, which broadly restricts certain character breaks, auto-phrase attempts to identify meaningful phrases and avoid breaking within them.
Browser support: The auto-phrase value is not universally supported. Unsupported browsers ignore the declaration, so provide a fallback.
.japanese-text {
word-break: normal;
word-break: auto-phrase;
}
Browsers that support auto-phrase use the second declaration. Other browsers retain normal.
word-break vs. overflow-wrap
The word-break and overflow-wrap properties both influence line wrapping, but they serve different purposes.
| Property | Purpose |
|---|---|
word-break |
Controls the rules for breaking lines within words and character sequences. |
overflow-wrap |
Allows otherwise unbreakable text to wrap when necessary to prevent overflow. |
For example, the following declaration allows a long word to break only when necessary to avoid overflowing its container:
.content {
overflow-wrap: anywhere;
}
By comparison, word-break: break-all introduces additional character-level breaking opportunities throughout non-CJK text.
For most ordinary paragraphs, prefer overflow-wrap: anywhere when the primary concern is unusually long words, URLs, or other unbroken strings.
Examples
Example 1: Default Word Breaking
The following example uses normal language-specific wrapping behavior.
.example-normal {
width: 200px;
word-break: normal;
}
Words normally wrap at spaces or other permitted line-breaking opportunities.
Example 2: Breaking Long Words
The break-all value allows long English words to split between characters.
.example-break {
width: 200px;
word-break: break-all;
}
This prevents long unbroken text from extending outside the container, but may produce less readable line breaks.
Example 3: Keeping CJK Text Together
The following example restricts line breaks within Chinese, Japanese, and Korean text.
.example-keep {
word-break: keep-all;
}
The exact result depends on the text, its language, and the available width.
Example 4: Handling Long URLs
Long URLs often contain few convenient line-breaking opportunities. The overflow-wrap property is usually better suited to this situation.
.url-text {
overflow-wrap: anywhere;
word-break: normal;
}
This preserves normal word-breaking rules while allowing otherwise unbreakable content to wrap.
Example 5: Deprecated break-word Value
The break-word value is retained for compatibility with existing stylesheets.
.legacy-text {
word-break: break-word;
}
For new projects, prefer overflow-wrap: anywhere with word-break: normal for equivalent wrapping behavior.
Inheritance
The word-break property is inherited. Child elements normally use the computed value of their parent unless they specify another value.
.parent {
word-break: break-all;
}
.child {
/* Inherits break-all */
}
The initial value is normal, and the property applies to text content within elements.
Because it is inherited, applying word-break to a container can affect headings, paragraphs, links, and other descendant text.
Practical Example
This example compares normal word breaking with break-all using the same long word inside two narrow containers.
HTML
<div class="word-break-demo">
<div class="word-break-example">
<strong>word-break: normal</strong>
<div class="word-break-box normal">
Supercalifragilisticexpialidocious
</div>
</div>
<div class="word-break-example">
<strong>word-break: break-all</strong>
<div class="word-break-box break-all">
Supercalifragilisticexpialidocious
</div>
</div>
</div>
CSS
.word-break-demo {
display: flex;
flex-wrap: wrap;
gap: 24px;
}
.word-break-example {
width: 180px;
}
.word-break-example strong {
display: block;
margin-bottom: 10px;
}
.word-break-box {
width: 100%;
min-height: 100px;
padding: 12px;
border: 1px solid #ccc;
background: #f5f5f5;
}
.word-break-box.normal {
word-break: normal;
}
.word-break-box.break-all {
word-break: break-all;
}
Result: The first box preserves normal word-breaking rules, so the long word may overflow horizontally. The second box allows the word to break between characters and fit within the available width.
The example demonstrates why break-all should be used selectively. Although it can prevent overflow, it may reduce readability when applied to ordinary text.
Common Mistakes
Using break-all for Every Paragraph
Applying word-break: break-all to all paragraphs can split ordinary words at unexpected positions.
/* Avoid applying this globally */
p {
word-break: break-all;
}
Use normal wrapping for ordinary text and introduce additional breaking opportunities only where necessary.
Confusing word-break with overflow-wrap
The word-break property changes line-breaking rules, while overflow-wrap is designed to handle otherwise unbreakable text that might overflow.
For long URLs and isolated long words, overflow-wrap: anywhere is often more appropriate.
Assuming keep-all Prevents Every Line Break
The keep-all value restricts certain breaks in CJK text. It does not prevent all line breaks or force the entire element onto one line.
To prevent normal wrapping entirely, use white-space: nowrap when appropriate.
Relying on auto-phrase Without a Fallback
The auto-phrase value has limited browser support. Provide a supported declaration before it to ensure predictable behavior.
Using break-word as the Preferred Modern Value
The break-word value is deprecated. Prefer overflow-wrap: anywhere when the goal is to break otherwise unbreakable text.
Important Considerations
- Readability: Breaking words between arbitrary characters can make paragraphs harder to read.
- Language: Line-breaking behavior depends on the writing system and the language of the text.
- HTML language attributes: Use the appropriate
langattribute for multilingual content. - Responsive layouts: Narrow containers may require additional wrapping rules to prevent overflow.
- Long URLs: Consider
overflow-wrap: anywhererather than applyingbreak-allto surrounding paragraphs. - Hyphenation: The
hyphensproperty controls hyphenation separately from word-breaking behavior. - White space: The
white-spaceproperty can influence whether text wraps at all. - Browser compatibility: Advanced values such as
auto-phrasemay not behave consistently across browsers.
For most English-language content, the default normal value is appropriate. Use other values when the content or writing system requires different line-breaking behavior.
Browser Support
The CSS word-break property is widely supported in modern browsers, including Chrome, Edge, Firefox, Safari, and Opera.
The commonly used normal, break-all, and keep-all values have broad support. The auto-phrase value has more limited availability and may require a fallback.
For current compatibility details, visit Can I Use? .
Specifications
The word-break property is defined in the CSS Text Module specifications, which describe line-breaking behavior for different languages and writing systems.
