Controls how white space is handled within an element.
Widely available
This feature is well established and works across many devices and browser versions.
Chrome
Edge
Firefox
Safari
Class
Style
ws-bs
white-space: break-spaces;
ws-n
white-space: normal;
ws-nw
white-space: nowrap;
ws-p
white-space: pre;
ws-pl
white-space: pre-line;
ws-pw
white-space: pre-wrap;
Normal
Initial value
The text will wrap normally, and multiple spaces will be collapsed into a single space.
London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill. London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill.
<divclass="tc-slate fs-lg ws-n">
Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall...
</div>
Break Spaces
The text will respect spaces and line breaks, allowing for wrapping at spaces.
London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill. London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill.
<divclass="tc-slate fs-lg ws-bs">
Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall...
</div>
No Wrap
The text will not wrap to the next line, and it will overflow the container if it exceeds the width.
London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill. London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill.
<divclass="o-x-auto">
<divclass="tc-slate fs-lg ws-nw">
Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall...
</div>
</div>
Pre
The text will be displayed as is, preserving spaces and line breaks.
London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill. London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill.
<divclass="tc-slate fs-lg ws-p">
Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall...
</div>
Pre-Line
The text will preserve line breaks but collapse multiple spaces into a single space.
London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill. London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill.
<divclass="tc-slate fs-lg ws-pl">
Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall...
</div>
Pre-Wrap
The text will preserve spaces and line breaks, and it will wrap when necessary.
London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill. London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill.
<divclass="tc-slate fs-lg ws-pw">
Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall...
</div>
Using utility variants
Learn how to override existing utilities based on the user's screen size or other factors, such as hover states.
Targeting different viewports
You can combine responsive breakpoints like sm:ws-*, md:ws-*, lg:ws-*, and xxl:ws-* to allow targeting specific utilities in different viewports.
Targeting hover states
Alternatively, you can apply :hover by using h:ws-* utility to override elements and change their values when hovering over them.