overflow-wrap
Widely availableSince 201897% of users
Also known as word-wrap. Breaks words if they would overflow the container instead of creating a scrollbar.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyClassic, with newer partsIt has worked everywhere since October 2018, and it keeps getting newer values.
Newer parts of overflow-wrap
anywhereBaseline Mar 2022, Widely Sept 2024
See how modern your own CSS is.Check your CSS →
Quick facts
- Initial value
normal- Inherited
- Yes
Quick example
.container { overflow-wrap: break-word; }Syntax
normal | break-word | anywhereExamples
Break long URLs in comments
.comment {
overflow-wrap: break-word;
word-break: break-word;
}
/* Long URLs like https://example.com/very-long-path-that-might-overflow will wrap */Prevent long words (URLs, email addresses) from breaking the layout by allowing them to wrap at any point.
Handle user-generated content safely
.user-content {
overflow-wrap: break-word;
max-width: 100%;
}
/* User pastes long text without spaces, still fits in box */When displaying user-generated content, overflow-wrap ensures it won't overflow its container.
Compare break-word vs normal
.card {
overflow-wrap: break-word; /* breaks long words */
white-space: pre-wrap; /* preserves spaces and line breaks */
}overflow-wrap only breaks words if no natural break point exists, respecting spaces and hyphens.
Common pitfalls
- overflow-wrap only breaks as last resortoverflow-wrap will break a long word ONLY if it has no other choice. If there's a space or hyphen, it breaks there first. Set word-break: break-all to force breaking at any character.
- Different from word-breakoverflow-wrap: break-word breaks only if the word would overflow. word-break: break-all breaks at any character. Choose based on whether you want natural breaks first or forced breaks.
- Need max-width for it to workoverflow-wrap only matters if there's a constraint forcing the text narrow. Without a max-width or container width, long words have space to fit and won't break.
overflow-wrap browser support
BaselineWidely availableThis feature is well established and works across many devices and browser versions. It has been available across browsers since 2018.Safe to use without fallbacks.
Usage97%of people can use this3% use a browser without it.
Browsers
23+
49+
7+
18+Mobile
25+Android
49+Android
7+iOS