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.
It is documented as part of the CSS Text specification.
Syntax
/* Usage Example */
.code-block {
white-space: pre;
font-family: monospace;
/* preserves all spaces and line breaks exactly as typed */
}
/* Syntax */
white-space: normal;
white-space: pre;
white-space: pre-wrap;
white-space: pre-line;
white-space: white-space-collapse;
white-space: text-wrap-mode;
/* Global values */
white-space: inherit;
white-space: initial;
white-space: revert;
white-space: revert-layer;
white-space: unset;
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.
1+
1+
1+
12+