The white-space property sets how spaces, tabs, and line breaks inside an element are handled — whether they collapse, stay as typed, and whether the text wraps.
Not deprecated. Core keywords work everywhere; some newer shorthand pairs and break-spaces need modern browsers.
Shorthand note:
Modern CSS treats white-space as a shorthand for white-space-collapse and text-wrap mode. The classic keywords (normal, pre, …) still work the same for everyday study.
Experimental:
white-space-trim is a related longhand in the spec and is not useful in browsers yet. Skip it for production.
With normal / nowrap / pre-line, tabs become spaces. Pair with tab-size when using pre or pre-wrap.
pre vs wrap
pre vs pre-wrap
Both keep formatting. Only pre-wrap (and break-spaces) soft-wraps inside the box.
html
Source newlines matter
Values that “preserve newlines” only keep breaks that exist in the HTML/text content.
Compatibility
Browser Support
white-space is a browser CSS property for text spacing and wrapping. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
white-space
Core values (normal, nowrap, pre, pre-wrap, pre-line) are supported in all major browsers. break-spaces and newer shorthand forms need modern engines.
97%Global support
Google Chrome1+
Full support
Mozilla Firefox1+
Full support
Apple Safari1+
Full support
Microsoft Edge12+
Full support
Opera4+
Full support
Samsung Internet1+
Full support
Internet Explorer5.5+
Core values
white-spaceWidely supported
Bottom line: Safe for everyday keywords. Treat break-spaces and multi-keyword shorthand as modern-only. This is not a JavaScript runtime API.
Remember
Key Takeaways
Two jobs: collapse/preserve whitespace, and allow/deny wrapping.
Default:normal collapses spaces and wraps text.
Code look: use pre or pre-wrap to keep formatting.
Inherited. Children follow the parent unless they set their own value.
One line:white-space decides whether spaces collapse and whether lines wrap.
Frequently Asked Questions
It controls how spaces, tabs, and line breaks inside an element are collapsed or preserved, and whether text wraps to the next line.
The initial value is normal: extra spaces collapse, and text wraps to fit the container.
Both collapse spaces, but nowrap keeps everything on one line. Text may overflow unless you also handle overflow.
Both preserve spaces and newlines. pre does not wrap long lines; pre-wrap wraps when the box is too narrow.
Yes. Setting it on a parent affects child text unless a child overrides it.
Core values are Baseline Widely available in all major browsers. Newer shorthand combinations and break-spaces have broader modern support. It is a browser CSS property, not a Node.js feature.