text-wrap
The text-wrap CSS property sets how lines break in text that overflows the container. It is a shorthand for text-wrap-style and text-wrap-mode.
Overview
The text-wrap CSS property sets how lines break in text that overflows the container. It is a shorthand for text-wrap-style and text-wrap-mode.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 114 | 114 | 121 | 17.4 | 114 | 17.4 | |
| Other | ||||||
| The text-wrap-mode CSS property controls whether the text inside an element is wrapped. The different values provide alternate ways of wrapping the content of a block element. It can also be set, and reset, using the text-wrap shorthand or the white-space shorthand. | 130 | 130 | 124 | 17.4 | 130 | 17.4 |
| CSS property | ||||||
nowrap | 130 | 130 | 124 | 17.4 | 130 | 17.4 |
wrap | 130 | 130 | 124 | 17.4 | 130 | 17.4 |
| Other | ||||||
| The text-wrap-style CSS property controls how text inside an element is wrapped. The different values provide alternate ways of wrapping the content of a block element. It can also be set, and reset, using the text-wrap shorthand. | 130 | 130 | 124 | 17.5 | 130 | 17.5 |
| CSS property | ||||||
auto | 130 | 130 | 124 | 17.5 | 130 | 17.5 |
stable | 130 | 130 | 124 | 17.5 | 130 | 17.5 |
nowrap | 114 | 114 | 124 | 17.4 | 114 | 17.4 |
stable | 130 | 130 | 121 | 17.5 | 130 | 17.5 |
wrap | 114 | 114 | 124 | 17.4 | 114 | 17.4 |
Syntax
/* Basic text wrapping */
p {
text-wrap: wrap;
}
/* Even line spacing */
h1 {
text-wrap: balance;
}
/* Prevent isolated words */
.article p {
text-wrap: pretty;
} Live demo
Use cases
Reading rhythm
Use text-wrap to improve how text wraps, aligns, or scales in dense layouts and editorial UI.
Language-aware text
Adjust typography when script direction, spacing, or writing rules differ across languages.
Cautions
- Test with real content rather than short placeholder strings because typographic behavior changes with length and language.
- Prefer the smallest rule that solves the layout problem so text remains easy to maintain.
Accessibility
- Typography choices should preserve readability at high zoom and on narrow screens.
- Avoid stylistic settings that reduce comprehension or make scanning harder.
Related links
Powered by web-features