white-space

Controls how white space (spaces, tabs, and newlines) inside an element is handled. It can be used to prevent text from wrapping or to preserve multiple spaces and line breaks.

Quick example

.code-block {
  white-space: pre;
  font-family: monospace;
  /* preserves all spaces and line breaks exactly as typed */
}

Quick facts

Initial value
normal
Inherited
Yes
Applies to
all elements
Animation type
discrete

Values

normalprepre-wrappre-linewhite-space-collapsetext-wrap-mode

white-space Browser Support

Widely available Since 2015 96% global usage

This feature is well established and works across many devices and browser versions. It has been available across browsers since 2015.

Safe to use without fallbacks.

1+
1+
1+
12+
ESC