text-wrap-mode CSS property

Baseline 2024
Newly available

Since October 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

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.

Note: The white-space-collapse and text-wrap-mode properties can be declared together using the white-space shorthand property.

Note: The name of this property is a placeholder, pending the CSSWG finding a better name.

Try it

text-wrap-mode: wrap;
text-wrap-mode: nowrap;
<section class="default-example" id="default-example">
  <div class="whole-content-wrapper">
    <p>Edit the text in the box:</p>
    <div class="transition-all" id="example-element">
      <p contenteditable="">
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatem aut
        cum eum id quos est.
      </p>
    </div>
  </div>
</section>
.whole-content-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

#example-element {
  border: 1px solid #c5c5c5;
  width: 250px;
}

Syntax

css
/* Keyword values */
text-wrap-mode: wrap;
text-wrap-mode: nowrap;

/* Global values */
text-wrap-mode: inherit;
text-wrap-mode: initial;
text-wrap-mode: revert;
text-wrap-mode: revert-layer;
text-wrap-mode: unset;

Values

This property specifies whether lines may wrap at unforced soft wrap opportunities. Possible values:

wrap

Text is wrapped across lines at appropriate characters (for example spaces, in languages like English that use space separators) to minimize overflow. This is the default value.

nowrap

Text does not wrap across lines. It will overflow its containing element rather than breaking onto a new line.

Formal definition

Initial valuewrap
Applies totext and block containers
Inheritedyes
Computed valueas specified
Animation typediscrete

Formal syntax

text-wrap-mode = 
wrap |
nowrap

Examples

Wrapping content

The default setting is to wrap the content so the text-wrap-mode property is not necessary. In this example the content will flow over to the next line so that it fits in the box, the last line is longer that the containing box so overflows.

HTML

html
<div class="box">CSS IS AWESOME</div>

CSS

css
.box {
  font-family: "Arial", sans-serif;
  font-weight: bold;
  font-size: 64px;
  box-sizing: border-box;
  border: 4px solid black;
  padding: 0px 3px;
  width: 223px;
  text-wrap-mode: wrap;
}

Result

Not wrapping content

In this example the content will not flow over to the next line so that it fits in the box as the content has been specifically told not to wrap with text-wrap-mode: nowrap;, the content is longer that the containing box so overflows.

HTML

html
<div class="box">CSS IS AWESOME</div>

CSS

css
.box {
  font-family: "Arial", sans-serif;
  font-weight: bold;
  font-size: 64px;
  box-sizing: border-box;
  border: 4px solid black;
  padding: 0px 3px;
  width: 223px;
  text-wrap-mode: nowrap;
}

Result

Specifications

Specification
CSS Text Module Level 4
# text-wrap-mode

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
text-wrap-mode
Chrome – Full support
Chrome 130 (Release date: 2024-10-15)
footnote Full support
Edge – Full support
Edge 130 (Release date: 2024-10-17)
footnote Full support
Firefox – Full support
Firefox 124 (Release date: 2024-03-19)
footnote Full support
Opera – Full support
Opera 115 (Release date: 2024-11-27)
footnote Full support
Safari – Full support
Safari 17.4 (Release date: 2024-03-05)
footnote Full support
Chrome Android – Full support
Chrome Android 130 (Release date: 2024-10-15)
footnote Full support
Firefox for Android – Full support
Firefox for Android 124 (Release date: 2024-03-19)
footnote Full support
Opera Android – Full support
Opera Android 86 (Release date: 2024-12-02)
footnote Full support
Safari on iOS – Full support
Safari on iOS 17.4 (Release date: 2024-03-05)
footnote Full support
Samsung Internet – Full support
Samsung Internet 28 (Release date: 2025-04-02)
footnote Full support
WebView Android – Full support
WebView Android 130 (Release date: 2024-10-15)
footnote Full support
WebView on iOS – Full support
WebView on iOS 17.4 (Release date: 2024-03-05)
footnote Full support
nowrap
Chrome – Full support
Chrome 130 (Release date: 2024-10-15)
footnote Full support
Edge – Full support
Edge 130 (Release date: 2024-10-17)
footnote Full support
Firefox – Full support
Firefox 124 (Release date: 2024-03-19)
footnote Full support
Opera – Full support
Opera 115 (Release date: 2024-11-27)
footnote Full support
Safari – Full support
Safari 17.4 (Release date: 2024-03-05)
footnote Full support
Chrome Android – Full support
Chrome Android 130 (Release date: 2024-10-15)
footnote Full support
Firefox for Android – Full support
Firefox for Android 124 (Release date: 2024-03-19)
footnote Full support
Opera Android – Full support
Opera Android 86 (Release date: 2024-12-02)
footnote Full support
Safari on iOS – Full support
Safari on iOS 17.4 (Release date: 2024-03-05)
footnote Full support
Samsung Internet – Full support
Samsung Internet 28 (Release date: 2025-04-02)
footnote Full support
WebView Android – Full support
WebView Android 130 (Release date: 2024-10-15)
footnote Full support
WebView on iOS – Full support
WebView on iOS 17.4 (Release date: 2024-03-05)
footnote Full support
wrap
Chrome – Full support
Chrome 130 (Release date: 2024-10-15)
footnote Full support
Edge – Full support
Edge 130 (Release date: 2024-10-17)
footnote Full support
Firefox – Full support
Firefox 124 (Release date: 2024-03-19)
footnote Full support
Opera – Full support
Opera 115 (Release date: 2024-11-27)
footnote Full support
Safari – Full support
Safari 17.4 (Release date: 2024-03-05)
footnote Full support
Chrome Android – Full support
Chrome Android 130 (Release date: 2024-10-15)
footnote Full support
Firefox for Android – Full support
Firefox for Android 124 (Release date: 2024-03-19)
footnote Full support
Opera Android – Full support
Opera Android 86 (Release date: 2024-12-02)
footnote Full support
Safari on iOS – Full support
Safari on iOS 17.4 (Release date: 2024-03-05)
footnote Full support
Samsung Internet – Full support
Samsung Internet 28 (Release date: 2025-04-02)
footnote Full support
WebView Android – Full support
WebView Android 130 (Release date: 2024-10-15)
footnote Full support
WebView on iOS – Full support
WebView on iOS 17.4 (Release date: 2024-03-05)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also