white-space-collapse

A modern property that gives you fine-grained control over how the browser 'collapses' multiple spaces into one. It is essentially the first part of the classic 'white-space' property, now split out for better control.

It is documented as part of the CSS Text specification.

/* Usage Example */
.chat-message {
  /* Preserves original line breaks but still collapses multiple spaces */
  white-space-collapse: preserve-breaks;
}

/* Syntax */
white-space-collapse: collapse;
white-space-collapse: preserve;
white-space-collapse: preserve-breaks;
white-space-collapse: preserve-spaces;
white-space-collapse: break-spaces;

/* Global values */
white-space-collapse: inherit;
white-space-collapse: initial;
white-space-collapse: revert;
white-space-collapse: revert-layer;
white-space-collapse: unset;
Newly available Since 2024 87% global usage

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

114+
124+
17.4+
114+
Kinsta

Your first month is free

Managed WordPress hosting for faster sites.

Learn more

New CSS drops.

Join 600+ readers who've survived clearfix hacks.

ESC