Understanding the word-break Property
The word-break CSS property sets whether line breaks appear wherever the text would otherwise overflow its content box. When text contains long unbreakable strings--such as URLs, technical terms, or international words--browsers face a decision point. Without proper handling, these strings can extend beyond their container boundaries, creating horizontal scrollbars or breaking responsive layouts.
The word-break property gives developers precise control over this behavior, ensuring text remains contained while maintaining readability across all device sizes and content types. Combined with other CSS text formatting techniques, proper word breaking prevents layout breakage while preserving the user experience.
Property Values: A Complete Reference
word-break: normal
The normal value uses default line break rules appropriate for the content's language. For Western languages, this means words stay together and only break at whitespace or designated hyphenation points. CJK (Chinese, Japanese, Korean) text follows different rules, allowing breaks at character boundaries.
.element {
word-break: normal;
}
Use normal when:
- Content consists of standard prose in Latin-based languages
- You want standard word-wrapping behavior
- User-generated content with typical word lengths
word-break: break-all
The break-all value prevents overflow by inserting line breaks between any two characters, even in the middle of words. This applies to all text except CJK characters, which maintain their own breaking rules.
.element {
word-break: break-all;
}
Use break-all for:
- Multi-language content with varying scripts
- Preventing horizontal scroll on mobile devices
- Data tables containing long technical terms
word-break: keep-all
The keep-all value ensures CJK text does not break mid-word, treating CJK characters similarly to Latin words. For non-CJK text, it behaves like normal.
.element {
word-break: keep-all;
}
Use keep-all for:
- Bilingual websites with significant CJK content
- Documents containing Korean, Japanese, or Chinese text
word-break vs. overflow-wrap: Key Differences
Many developers confuse word-break with overflow-wrap, but they serve subtly different purposes:
| Property | Behavior |
|---|---|
overflow-wrap: break-word | Only breaks long words when they would otherwise overflow |
word-break: break-all | Breaks at any character boundary when the line is full |
Code comparison:
/* overflow-wrap: break-word */
.container {
width: 150px;
overflow-wrap: break-word;
}
/* word-break: break-all */
.container {
width: 150px;
word-break: break-all;
}
In practice, overflow-wrap is often preferred for general content because it maintains word integrity until breaking is absolutely necessary. word-break: break-all is more aggressive and useful when uniform line lengths matter more than word preservation.
Practical Implementation Patterns
Handling Long URLs
Long URLs are one of the most common causes of text overflow:
.preserve-urls {
word-break: break-all;
overflow-wrap: anywhere;
}
Responsive Typography
Use a mobile-first approach with media queries to ensure proper text handling across all screen sizes. Proper typography breaks are essential for responsive web design performance:
.content-text {
word-break: normal;
}
@media (max-width: 768px) {
.content-text {
word-break: break-word;
}
}
Data Tables and Technical Content
td, th {
word-break: break-all;
overflow-wrap: anywhere;
}
These patterns become especially important when optimizing for Core Web Vitals, where layout stability directly impacts user experience scores.
Why proper text breaking matters for your website
Prevents Horizontal Scroll
Keep content contained within viewport boundaries on all device sizes
Responsive Ready
Handle diverse content types gracefully across responsive breakpoints
International Support
Proper handling of CJK characters and mixed-language content
URL Safe
Prevent long URLs from breaking your layout designs
Common Pitfalls and Solutions
1. Overusing break-all
Applying break-all globally can make text difficult to read by breaking common words unnecessarily. Solution: Use it selectively on specific elements.
2. Forgetting Language Context
Hyphens and some breaking behaviors require proper language declaration. Solution: Set the HTML lang attribute or use content-language in CSS.
3. Not Testing with Real Content
Edge cases like user-generated content, technical documentation, and international text reveal overflow issues that placeholder text won't show. Solution: Test with actual content before deployment. Our web development team can help identify and resolve these issues during development.
4. Ignoring Accessibility
Breaking words mid-character can affect screen reader behavior. Solution: Test with assistive technologies when using aggressive breaking rules. Ensuring your site remains accessible to all users is a core part of our accessibility services.