CKTIS / CSS
white-space — whitespace handling and text wrapping
The white-space property controls how the browser processes spaces, tabs, and source line breaks, and whether text may wrap automatically. It changes rendering rather than the document’s underlying data.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
white-space: normal | pre | pre-wrap | pre-line | <'white-space-collapse'> || <'text-wrap-mode'> || <'white-space-trim'>;white-space controls whitespace processing and automatic text wrapping. Its initial value, normal, collapses whitespace and permits wrapping. Source line breaks therefore do not necessarily produce visible new lines.
nowrap collapses whitespace but disables automatic wrapping. pre preserves spaces, tabs, and line breaks without automatic wrapping. pre-wrap preserves them and permits wrapping. pre-line preserves line breaks but collapses spaces and tabs, while permitting wrapping.
break-spaces resembles pre-wrap, but permits a wrap after every preserved space and tab. Preserved trailing whitespace occupies space instead of “hanging” beyond the line end. This can affect sizing.
In CSS Text Level 4, this is a shorthand for white-space-collapse, text-wrap-mode, and white-space-trim; omitted components reset to their initial values. Draft specification syntax does not guarantee browser support. white-space does not replace word-breaking rules; unwrappable content can overflow its container.
Examples
<!doctype html>
<meta charset="utf-8">
<title>white-space</title>
<style>
.sample { width: 40ch; font: 16px/24px monospace; }
.collapsed { white-space: normal; }
.preserved { white-space: pre; }
</style>
<div class="sample collapsed">A B
C</div>
<div class="sample preserved">A B
C</div>Result
A B C A B C
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.